From bf40cd912dc1d83d8123d29a59ba72e52d9ef4b4 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:05 +0000 Subject: [PATCH] chore(internal): codegen related update --- .../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 391164d2..e5ea58a3 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 @@ -35,15 +35,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() @@ -106,27 +105,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") @@ -141,17 +161,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")) @@ -161,19 +185,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") @@ -189,9 +207,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") @@ -199,9 +215,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 @@ -209,24 +223,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) @@ -236,7 +249,6 @@ class FunctionCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .functionData() * .name() @@ -244,8 +256,7 @@ class FunctionCreateParams private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -264,60 +275,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)) @@ -326,40 +328,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)) @@ -368,10 +368,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)) @@ -380,75 +379,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 */ @@ -457,7 +438,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) @@ -465,11 +447,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() @@ -477,8 +457,7 @@ class FunctionCreateParams private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionCreateParams]. */ @@ -490,331 +469,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) @@ -838,44 +720,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 */ @@ -891,19 +774,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 { @@ -916,62 +796,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 @@ -979,16 +868,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 { @@ -997,13 +885,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]. */ @@ -1013,57 +899,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. @@ -1073,8 +945,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 { @@ -1085,23 +956,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, } @@ -1125,7 +996,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) { @@ -1140,16 +1011,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() @@ -1158,11 +1032,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 */ @@ -1171,28 +1045,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 @@ -1200,17 +1077,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 { @@ -1219,14 +1095,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]. */ @@ -1237,19 +1111,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)) @@ -1257,56 +1127,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) @@ -1324,39 +1183,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 */ @@ -1371,11 +1231,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) } /** @@ -1391,65 +1249,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") @@ -1470,9 +1349,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 @@ -1488,20 +1365,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 { @@ -1510,7 +1386,6 @@ class FunctionCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: - * * ```java * .bundleId() * .location() @@ -1518,8 +1393,7 @@ class FunctionCreateParams private constructor( * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1530,38 +1404,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 { @@ -1575,17 +1451,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 { @@ -1593,57 +1463,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 @@ -1657,23 +1514,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, } @@ -1681,8 +1540,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) { @@ -1693,11 +1552,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) { @@ -1708,20 +1567,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() @@ -1730,11 +1592,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 */ @@ -1743,35 +1605,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 @@ -1779,18 +1647,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 { @@ -1799,15 +1666,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]. */ @@ -1816,37 +1681,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 { @@ -1854,47 +1713,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") @@ -1915,33 +1771,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]. */ @@ -1949,29 +1803,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 { @@ -1979,50 +1832,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 @@ -2043,29 +1887,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) { @@ -2077,36 +1925,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() @@ -2115,11 +1969,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 */ @@ -2128,21 +1982,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 @@ -2156,23 +2010,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, } @@ -2180,8 +2036,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) { @@ -2192,11 +2048,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) { @@ -2207,20 +2063,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() @@ -2229,11 +2088,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 */ @@ -2242,14 +2101,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. @@ -2259,8 +2117,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 { @@ -2271,23 +2128,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, } @@ -2311,7 +2168,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) { @@ -2326,16 +2183,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() @@ -2344,11 +2204,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 */ @@ -2357,28 +2217,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 @@ -2386,17 +2249,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 { @@ -2405,14 +2267,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]. */ @@ -2423,69 +2283,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. @@ -2495,8 +2338,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 { @@ -2507,23 +2349,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, } @@ -2547,7 +2389,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) { @@ -2562,16 +2404,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() @@ -2580,11 +2425,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 */ @@ -2593,26 +2438,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 @@ -2620,22 +2466,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]. */ @@ -2646,63 +2490,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 */ @@ -2711,24 +2537,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 { @@ -2752,15 +2576,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 { @@ -2769,18 +2590,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) { @@ -2794,11 +2614,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) { @@ -2812,20 +2632,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() @@ -2834,12 +2657,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 */ @@ -2849,15 +2680,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") @@ -2865,12 +2694,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 @@ -2878,18 +2705,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 { @@ -2898,14 +2724,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]. */ @@ -2917,114 +2741,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 { @@ -3072,11 +2874,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 { @@ -3102,8 +2902,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) { @@ -3128,7 +2928,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) { @@ -3152,17 +2952,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() @@ -3171,11 +2974,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 */ @@ -3184,18 +2987,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 ac1320ef..bf5891ce 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 @@ -35,15 +35,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() @@ -106,27 +105,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") @@ -141,17 +161,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")) @@ -161,19 +185,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") @@ -189,9 +207,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") @@ -199,9 +215,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 @@ -209,24 +223,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) @@ -236,7 +249,6 @@ class FunctionReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .functionData() * .name() @@ -244,8 +256,7 @@ class FunctionReplaceParams private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -264,60 +275,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)) @@ -326,40 +328,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)) @@ -368,10 +368,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)) @@ -380,75 +379,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 */ @@ -457,7 +438,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) @@ -465,11 +447,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() @@ -477,8 +457,7 @@ class FunctionReplaceParams private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionReplaceParams]. */ @@ -490,331 +469,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) @@ -838,44 +720,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 */ @@ -891,19 +774,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 { @@ -916,62 +796,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 @@ -979,16 +868,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 { @@ -997,13 +885,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]. */ @@ -1013,57 +899,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. @@ -1073,8 +945,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 { @@ -1085,23 +956,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, } @@ -1125,7 +996,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) { @@ -1140,16 +1011,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() @@ -1158,11 +1032,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 */ @@ -1171,28 +1045,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 @@ -1200,17 +1077,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 { @@ -1219,14 +1095,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]. */ @@ -1237,19 +1111,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)) @@ -1257,56 +1127,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) @@ -1324,39 +1183,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 */ @@ -1371,11 +1231,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) } /** @@ -1391,65 +1249,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") @@ -1470,9 +1349,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 @@ -1488,20 +1365,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 { @@ -1510,7 +1386,6 @@ class FunctionReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: - * * ```java * .bundleId() * .location() @@ -1518,8 +1393,7 @@ class FunctionReplaceParams private constructor( * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1530,38 +1404,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 { @@ -1575,17 +1451,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 { @@ -1593,57 +1463,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 @@ -1657,23 +1514,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, } @@ -1681,8 +1540,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) { @@ -1693,11 +1552,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) { @@ -1708,20 +1567,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() @@ -1730,11 +1592,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 */ @@ -1743,35 +1605,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 @@ -1779,18 +1647,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 { @@ -1799,15 +1666,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]. */ @@ -1816,37 +1681,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 { @@ -1854,47 +1713,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") @@ -1915,33 +1771,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]. */ @@ -1949,29 +1803,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 { @@ -1979,50 +1832,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 @@ -2043,29 +1887,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) { @@ -2077,36 +1925,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() @@ -2115,11 +1969,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 */ @@ -2128,21 +1982,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 @@ -2156,23 +2010,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, } @@ -2180,8 +2036,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) { @@ -2192,11 +2048,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) { @@ -2207,20 +2063,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() @@ -2229,11 +2088,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 */ @@ -2242,14 +2101,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. @@ -2259,8 +2117,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 { @@ -2271,23 +2128,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, } @@ -2311,7 +2168,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) { @@ -2326,16 +2183,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() @@ -2344,11 +2204,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 */ @@ -2357,28 +2217,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 @@ -2386,17 +2249,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 { @@ -2405,14 +2267,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]. */ @@ -2423,69 +2283,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. @@ -2495,8 +2338,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 { @@ -2507,23 +2349,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, } @@ -2547,7 +2389,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) { @@ -2562,16 +2404,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() @@ -2580,11 +2425,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 */ @@ -2593,26 +2438,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 @@ -2620,22 +2466,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]. */ @@ -2646,63 +2490,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 */ @@ -2711,24 +2537,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 { @@ -2752,15 +2576,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 { @@ -2769,18 +2590,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) { @@ -2794,11 +2614,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) { @@ -2812,20 +2632,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() @@ -2834,12 +2657,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 */ @@ -2849,15 +2680,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") @@ -2865,12 +2694,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 @@ -2878,18 +2705,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 { @@ -2898,14 +2724,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]. */ @@ -2917,114 +2741,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 { @@ -3072,11 +2874,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 { @@ -3102,8 +2902,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) { @@ -3128,7 +2928,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) { @@ -3152,17 +2952,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() @@ -3171,11 +2974,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 */ @@ -3184,18 +2987,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 d12ed9e3..d052b992 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 @@ -35,16 +35,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 */ @@ -84,41 +84,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")) @@ -133,9 +147,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") @@ -143,9 +155,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 @@ -153,27 +163,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]. */ @@ -187,15 +195,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)) @@ -204,25 +211,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)) @@ -231,10 +239,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)) @@ -243,10 +248,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)) @@ -255,62 +259,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 */ @@ -319,7 +313,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) @@ -327,17 +322,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]. */ @@ -350,287 +342,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) @@ -660,49 +571,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 */ @@ -719,22 +631,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 { @@ -749,66 +659,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 @@ -816,16 +736,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 { @@ -834,13 +753,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]. */ @@ -850,57 +767,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. @@ -910,8 +813,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 { @@ -922,23 +824,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, } @@ -962,7 +864,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) { @@ -977,16 +879,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() @@ -995,11 +900,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 */ @@ -1008,28 +913,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 @@ -1037,17 +945,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 { @@ -1056,14 +963,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]. */ @@ -1074,19 +979,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)) @@ -1094,56 +995,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) @@ -1161,39 +1051,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 */ @@ -1208,11 +1099,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) } /** @@ -1228,65 +1117,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") @@ -1307,9 +1217,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 @@ -1325,20 +1233,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 { @@ -1347,7 +1254,6 @@ class FunctionUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: - * * ```java * .bundleId() * .location() @@ -1355,8 +1261,7 @@ class FunctionUpdateParams private constructor( * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1367,38 +1272,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 { @@ -1412,17 +1319,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 { @@ -1430,57 +1331,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 @@ -1494,23 +1382,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, } @@ -1518,8 +1408,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) { @@ -1530,11 +1420,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) { @@ -1545,20 +1435,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() @@ -1567,11 +1460,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 */ @@ -1580,35 +1473,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 @@ -1616,18 +1515,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 { @@ -1636,15 +1534,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]. */ @@ -1653,37 +1549,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 { @@ -1691,47 +1581,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") @@ -1752,33 +1639,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]. */ @@ -1786,29 +1671,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 { @@ -1816,50 +1700,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 @@ -1880,29 +1755,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) { @@ -1914,36 +1793,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() @@ -1952,11 +1837,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 */ @@ -1965,21 +1850,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 @@ -1993,23 +1878,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, } @@ -2017,8 +1904,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) { @@ -2029,11 +1916,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) { @@ -2044,20 +1931,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() @@ -2066,11 +1956,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 */ @@ -2079,14 +1969,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. @@ -2096,8 +1985,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 { @@ -2108,23 +1996,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, } @@ -2148,7 +2036,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) { @@ -2163,16 +2051,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() @@ -2181,11 +2072,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 */ @@ -2194,28 +2085,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 @@ -2223,17 +2117,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 { @@ -2242,14 +2135,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]. */ @@ -2260,69 +2151,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. @@ -2332,8 +2206,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 { @@ -2344,23 +2217,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, } @@ -2384,7 +2257,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) { @@ -2399,16 +2272,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() @@ -2417,11 +2293,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 */ @@ -2430,13 +2306,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 @@ -2445,22 +2324,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]. */ @@ -2469,46 +2346,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 */ @@ -2522,14 +2394,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() } }