From d1a6af61218a297d88b4743924f826da2bea6552 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 03:40:03 +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 | 4065 +++++++++-------- .../braintrustdata/api/models/Experiment.kt | 491 +- .../api/models/ExperimentCreateParams.kt | 917 ++-- .../api/models/ExperimentDeleteParams.kt | 250 +- .../api/models/ExperimentEvent.kt | 1729 +++---- .../api/models/ExperimentFeedbackParams.kt | 380 +- .../api/models/ExperimentFetchParams.kt | 469 +- .../api/models/ExperimentFetchPostParams.kt | 1175 ++--- .../api/models/ExperimentInsertParams.kt | 375 +- .../api/models/ExperimentListPage.kt | 148 +- .../api/models/ExperimentListPageAsync.kt | 184 +- .../api/models/ExperimentListParams.kt | 465 +- .../api/models/ExperimentRetrieveParams.kt | 212 +- .../api/models/ExperimentSummarizeParams.kt | 299 +- .../api/models/ExperimentUpdateParams.kt | 787 ++-- .../api/models/FeedbackDatasetItem.kt | 384 +- .../api/models/FeedbackExperimentItem.kt | 535 ++- .../api/models/FeedbackProjectLogsItem.kt | 535 ++- .../api/models/FeedbackResponseSchema.kt | 163 +- .../api/models/FetchDatasetEventsResponse.kt | 160 +- .../models/FetchExperimentEventsResponse.kt | 157 +- .../models/FetchProjectLogsEventsResponse.kt | 154 +- .../com/braintrustdata/api/models/Function.kt | 2273 ++++----- .../api/models/FunctionCreateParams.kt | 2383 +++++----- .../api/models/FunctionDeleteParams.kt | 249 +- .../api/models/FunctionInvokeParams.kt | 2775 +++++------ .../api/models/FunctionInvokeResponse.kt | 93 +- .../api/models/FunctionListPage.kt | 140 +- .../api/models/FunctionListPageAsync.kt | 181 +- .../api/models/FunctionListParams.kt | 499 +- .../api/models/FunctionReplaceParams.kt | 2383 +++++----- .../api/models/FunctionRetrieveParams.kt | 212 +- .../api/models/FunctionUpdateParams.kt | 1937 ++++---- .../com/braintrustdata/api/models/Group.kt | 305 +- .../api/models/GroupCreateParams.kt | 622 +-- .../api/models/GroupDeleteParams.kt | 246 +- .../api/models/GroupListPage.kt | 134 +- .../api/models/GroupListPageAsync.kt | 167 +- .../api/models/GroupListParams.kt | 427 +- .../api/models/GroupReplaceParams.kt | 623 +-- .../api/models/GroupRetrieveParams.kt | 209 +- .../api/models/GroupUpdateParams.kt | 628 +-- .../api/models/InsertDatasetEvent.kt | 1242 ++--- .../api/models/InsertEventsResponse.kt | 138 +- .../api/models/InsertExperimentEvent.kt | 2135 +++++---- .../api/models/InsertProjectLogsEvent.kt | 2077 +++++---- .../api/models/MetricSummary.kt | 195 +- .../api/models/OnlineScoreConfig.kt | 603 +-- .../braintrustdata/api/models/Organization.kt | 222 +- .../api/models/OrganizationDeleteParams.kt | 250 +- .../api/models/OrganizationListPage.kt | 153 +- .../api/models/OrganizationListPageAsync.kt | 181 +- .../api/models/OrganizationListParams.kt | 417 +- .../models/OrganizationMemberUpdateParams.kt | 1013 ++-- .../api/models/OrganizationRetrieveParams.kt | 212 +- .../api/models/OrganizationUpdateParams.kt | 500 +- .../models/PatchOrganizationMembersOutput.kt | 225 +- .../com/braintrustdata/api/models/Project.kt | 216 +- .../api/models/ProjectCreateParams.kt | 439 +- .../api/models/ProjectDeleteParams.kt | 246 +- .../api/models/ProjectListPage.kt | 140 +- .../api/models/ProjectListPageAsync.kt | 183 +- .../api/models/ProjectListParams.kt | 427 +- .../api/models/ProjectLogFeedbackParams.kt | 380 +- .../api/models/ProjectLogFetchParams.kt | 469 +- .../api/models/ProjectLogFetchPostParams.kt | 1175 ++--- .../api/models/ProjectLogInsertParams.kt | 375 +- .../api/models/ProjectLogsEvent.kt | 1753 +++---- .../api/models/ProjectRetrieveParams.kt | 212 +- .../braintrustdata/api/models/ProjectScore.kt | 648 +-- .../api/models/ProjectScoreCategory.kt | 124 +- .../api/models/ProjectScoreConfig.kt | 202 +- .../api/models/ProjectScoreCreateParams.kt | 872 ++-- .../api/models/ProjectScoreDeleteParams.kt | 250 +- .../api/models/ProjectScoreListPage.kt | 153 +- .../api/models/ProjectScoreListPageAsync.kt | 181 +- .../api/models/ProjectScoreListParams.kt | 671 +-- .../api/models/ProjectScoreReplaceParams.kt | 873 ++-- .../api/models/ProjectScoreRetrieveParams.kt | 212 +- .../api/models/ProjectScoreUpdateParams.kt | 859 ++-- .../api/models/ProjectSettings.kt | 112 +- .../braintrustdata/api/models/ProjectTag.kt | 223 +- .../api/models/ProjectTagCreateParams.kt | 444 +- .../api/models/ProjectTagDeleteParams.kt | 250 +- .../api/models/ProjectTagListPage.kt | 148 +- .../api/models/ProjectTagListPageAsync.kt | 184 +- .../api/models/ProjectTagListParams.kt | 465 +- .../api/models/ProjectTagReplaceParams.kt | 445 +- .../api/models/ProjectTagRetrieveParams.kt | 212 +- .../api/models/ProjectTagUpdateParams.kt | 432 +- .../api/models/ProjectUpdateParams.kt | 439 +- .../com/braintrustdata/api/models/Prompt.kt | 581 ++- .../api/models/PromptCreateParams.kt | 628 +-- .../braintrustdata/api/models/PromptData.kt | 3351 +++++++------- .../api/models/PromptDeleteParams.kt | 246 +- .../api/models/PromptListPage.kt | 134 +- .../api/models/PromptListPageAsync.kt | 167 +- .../api/models/PromptListParams.kt | 499 +- .../api/models/PromptOptions.kt | 2929 ++++++------ .../api/models/PromptReplaceParams.kt | 628 +-- .../api/models/PromptRetrieveParams.kt | 212 +- .../api/models/PromptUpdateParams.kt | 503 +- .../com/braintrustdata/api/models/RepoInfo.kt | 275 +- .../com/braintrustdata/api/models/Role.kt | 555 +-- .../api/models/RoleCreateParams.kt | 858 ++-- .../api/models/RoleDeleteParams.kt | 246 +- .../braintrustdata/api/models/RoleListPage.kt | 134 +- .../api/models/RoleListPageAsync.kt | 167 +- .../api/models/RoleListParams.kt | 427 +- .../api/models/RoleReplaceParams.kt | 859 ++-- .../api/models/RoleRetrieveParams.kt | 209 +- .../api/models/RoleUpdateParams.kt | 1101 ++--- .../braintrustdata/api/models/ScoreSummary.kt | 174 +- .../api/models/SpanAttributes.kt | 168 +- .../braintrustdata/api/models/SpanIFrame.kt | 279 +- .../api/models/SpanIframeCreateParams.kt | 520 ++- .../api/models/SpanIframeDeleteParams.kt | 250 +- .../api/models/SpanIframeListPage.kt | 148 +- .../api/models/SpanIframeListPageAsync.kt | 184 +- .../api/models/SpanIframeListParams.kt | 435 +- .../api/models/SpanIframeReplaceParams.kt | 520 ++- .../api/models/SpanIframeRetrieveParams.kt | 212 +- .../api/models/SpanIframeUpdateParams.kt | 476 +- .../api/models/SummarizeDatasetResponse.kt | 186 +- .../api/models/SummarizeExperimentResponse.kt | 388 +- .../api/models/TopLevelHelloWorldParams.kt | 202 +- .../com/braintrustdata/api/models/User.kt | 195 +- .../braintrustdata/api/models/UserListPage.kt | 134 +- .../api/models/UserListPageAsync.kt | 167 +- .../api/models/UserListParams.kt | 756 +-- .../api/models/UserRetrieveParams.kt | 209 +- .../com/braintrustdata/api/models/View.kt | 394 +- .../api/models/ViewCreateParams.kt | 688 +-- .../com/braintrustdata/api/models/ViewData.kt | 105 +- .../api/models/ViewDataSearch.kt | 204 +- .../api/models/ViewDeleteParams.kt | 458 +- .../braintrustdata/api/models/ViewListPage.kt | 134 +- .../api/models/ViewListPageAsync.kt | 167 +- .../api/models/ViewListParams.kt | 589 ++- .../braintrustdata/api/models/ViewOptions.kt | 304 +- .../api/models/ViewReplaceParams.kt | 689 +-- .../api/models/ViewRetrieveParams.kt | 313 +- .../api/models/ViewUpdateParams.kt | 675 +-- .../api/services/async/AclServiceAsync.kt | 162 +- .../api/services/async/AclServiceAsyncImpl.kt | 357 +- .../services/async/AiSecretServiceAsync.kt | 201 +- .../async/AiSecretServiceAsyncImpl.kt | 416 +- .../api/services/async/ApiKeyServiceAsync.kt | 112 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 248 +- .../api/services/async/DatasetServiceAsync.kt | 271 +- .../services/async/DatasetServiceAsyncImpl.kt | 585 +-- .../api/services/async/EnvVarServiceAsync.kt | 159 +- .../services/async/EnvVarServiceAsyncImpl.kt | 348 +- .../api/services/async/EvalServiceAsync.kt | 39 +- .../services/async/EvalServiceAsyncImpl.kt | 71 +- .../services/async/ExperimentServiceAsync.kt | 301 +- .../async/ExperimentServiceAsyncImpl.kt | 585 +-- .../services/async/FunctionServiceAsync.kt | 187 +- .../async/FunctionServiceAsyncImpl.kt | 417 +- .../api/services/async/GroupServiceAsync.kt | 165 +- .../services/async/GroupServiceAsyncImpl.kt | 360 +- .../async/OrganizationServiceAsync.kt | 129 +- .../async/OrganizationServiceAsyncImpl.kt | 252 +- .../async/ProjectScoreServiceAsync.kt | 195 +- .../async/ProjectScoreServiceAsyncImpl.kt | 360 +- .../api/services/async/ProjectServiceAsync.kt | 136 +- .../services/async/ProjectServiceAsyncImpl.kt | 308 +- .../services/async/ProjectTagServiceAsync.kt | 180 +- .../async/ProjectTagServiceAsyncImpl.kt | 360 +- .../api/services/async/PromptServiceAsync.kt | 164 +- .../services/async/PromptServiceAsyncImpl.kt | 360 +- .../api/services/async/RoleServiceAsync.kt | 162 +- .../services/async/RoleServiceAsyncImpl.kt | 360 +- .../services/async/SpanIframeServiceAsync.kt | 179 +- .../async/SpanIframeServiceAsyncImpl.kt | 360 +- .../services/async/TopLevelServiceAsync.kt | 44 +- .../async/TopLevelServiceAsyncImpl.kt | 57 +- .../api/services/async/UserServiceAsync.kt | 67 +- .../services/async/UserServiceAsyncImpl.kt | 132 +- .../api/services/async/ViewServiceAsync.kt | 147 +- .../services/async/ViewServiceAsyncImpl.kt | 360 +- .../async/organizations/MemberServiceAsync.kt | 49 +- .../organizations/MemberServiceAsyncImpl.kt | 71 +- .../async/projects/LogServiceAsync.kt | 127 +- .../async/projects/LogServiceAsyncImpl.kt | 242 +- .../api/services/blocking/AclService.kt | 150 +- .../api/services/blocking/AclServiceImpl.kt | 321 +- .../api/services/blocking/AiSecretService.kt | 195 +- .../services/blocking/AiSecretServiceImpl.kt | 375 +- .../api/services/blocking/ApiKeyService.kt | 106 +- .../services/blocking/ApiKeyServiceImpl.kt | 218 +- .../api/services/blocking/DatasetService.kt | 251 +- .../services/blocking/DatasetServiceImpl.kt | 533 +-- .../api/services/blocking/EnvVarService.kt | 157 +- .../services/blocking/EnvVarServiceImpl.kt | 311 +- .../api/services/blocking/EvalService.kt | 35 +- .../api/services/blocking/EvalServiceImpl.kt | 68 +- .../services/blocking/ExperimentService.kt | 273 +- .../blocking/ExperimentServiceImpl.kt | 558 ++- .../api/services/blocking/FunctionService.kt | 184 +- .../services/blocking/FunctionServiceImpl.kt | 362 +- .../api/services/blocking/GroupService.kt | 161 +- .../api/services/blocking/GroupServiceImpl.kt | 311 +- .../services/blocking/OrganizationService.kt | 109 +- .../blocking/OrganizationServiceImpl.kt | 239 +- .../services/blocking/ProjectScoreService.kt | 169 +- .../blocking/ProjectScoreServiceImpl.kt | 343 +- .../api/services/blocking/ProjectService.kt | 136 +- .../services/blocking/ProjectServiceImpl.kt | 266 +- .../services/blocking/ProjectTagService.kt | 169 +- .../blocking/ProjectTagServiceImpl.kt | 341 +- .../api/services/blocking/PromptService.kt | 165 +- .../services/blocking/PromptServiceImpl.kt | 311 +- .../api/services/blocking/RoleService.kt | 161 +- .../api/services/blocking/RoleServiceImpl.kt | 310 +- .../services/blocking/SpanIframeService.kt | 168 +- .../blocking/SpanIframeServiceImpl.kt | 341 +- .../api/services/blocking/TopLevelService.kt | 40 +- .../services/blocking/TopLevelServiceImpl.kt | 55 +- .../api/services/blocking/UserService.kt | 62 +- .../api/services/blocking/UserServiceImpl.kt | 110 +- .../api/services/blocking/ViewService.kt | 153 +- .../api/services/blocking/ViewServiceImpl.kt | 310 +- .../blocking/organizations/MemberService.kt | 47 +- .../organizations/MemberServiceImpl.kt | 69 +- .../services/blocking/projects/LogService.kt | 112 +- .../blocking/projects/LogServiceImpl.kt | 233 +- .../braintrustdata/api/TestServerExtension.kt | 10 +- .../api/core/PhantomReachableTest.kt | 8 +- .../com/braintrustdata/api/core/ValuesTest.kt | 22 +- .../api/core/http/HeadersTest.kt | 67 +- .../api/core/http/QueryParamsTest.kt | 53 +- .../api/core/http/RetryingHttpClientTest.kt | 26 +- .../api/core/http/SerializerTest.kt | 31 +- .../braintrustdata/api/models/AISecretTest.kt | 48 +- .../api/models/AclBatchUpdateParamsTest.kt | 155 +- .../api/models/AclBatchUpdateResponseTest.kt | 113 +- .../api/models/AclCreateParamsTest.kt | 77 +- .../api/models/AclDeleteParamsTest.kt | 18 +- .../api/models/AclFindAndDeleteParamsTest.kt | 77 +- .../api/models/AclListParamsTest.kt | 69 +- .../api/models/AclRetrieveParamsTest.kt | 19 +- .../com/braintrustdata/api/models/AclTest.kt | 47 +- .../api/models/AiSecretCreateParamsTest.kt | 76 +- .../api/models/AiSecretDeleteParamsTest.kt | 21 +- .../models/AiSecretFindAndDeleteParamsTest.kt | 28 +- .../api/models/AiSecretListParamsTest.kt | 67 +- .../api/models/AiSecretReplaceParamsTest.kt | 76 +- .../api/models/AiSecretRetrieveParamsTest.kt | 21 +- .../api/models/AiSecretUpdateParamsTest.kt | 88 +- .../api/models/ApiKeyCreateParamsTest.kt | 28 +- .../api/models/ApiKeyDeleteParamsTest.kt | 19 +- .../api/models/ApiKeyListParamsTest.kt | 58 +- .../api/models/ApiKeyRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/ApiKeyTest.kt | 31 +- .../ChatCompletionContentPartImageTest.kt | 33 +- .../ChatCompletionContentPartTextTest.kt | 16 +- .../ChatCompletionMessageToolCallTest.kt | 37 +- .../api/models/CodeBundleTest.kt | 75 +- .../api/models/CreateApiKeyOutputTest.kt | 36 +- .../models/CrossObjectInsertResponseTest.kt | 76 +- .../api/models/DataSummaryTest.kt | 8 +- .../api/models/DatasetCreateParamsTest.kt | 77 +- .../api/models/DatasetDeleteParamsTest.kt | 19 +- .../api/models/DatasetEventTest.kt | 98 +- .../api/models/DatasetFeedbackParamsTest.kt | 127 +- .../api/models/DatasetFetchParamsTest.kt | 65 +- .../api/models/DatasetFetchPostParamsTest.kt | 75 +- .../api/models/DatasetInsertParamsTest.kt | 168 +- .../api/models/DatasetListParamsTest.kt | 70 +- .../api/models/DatasetRetrieveParamsTest.kt | 21 +- .../api/models/DatasetSummarizeParamsTest.kt | 51 +- .../braintrustdata/api/models/DatasetTest.kt | 52 +- .../api/models/DatasetUpdateParamsTest.kt | 78 +- .../api/models/EnvVarCreateParamsTest.kt | 66 +- .../api/models/EnvVarDeleteParamsTest.kt | 19 +- .../api/models/EnvVarListParamsTest.kt | 52 +- .../api/models/EnvVarListResponseTest.kt | 44 +- .../api/models/EnvVarReplaceParamsTest.kt | 66 +- .../api/models/EnvVarRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/EnvVarTest.kt | 31 +- .../api/models/EnvVarUpdateParamsTest.kt | 67 +- .../api/models/EvalCreateParamsTest.kt | 339 +- .../api/models/ExperimentCreateParamsTest.kt | 172 +- .../api/models/ExperimentDeleteParamsTest.kt | 23 +- .../api/models/ExperimentEventTest.kt | 214 +- .../models/ExperimentFeedbackParamsTest.kt | 157 +- .../api/models/ExperimentFetchParamsTest.kt | 69 +- .../models/ExperimentFetchPostParamsTest.kt | 75 +- .../api/models/ExperimentInsertParamsTest.kt | 339 +- .../api/models/ExperimentListParamsTest.kt | 70 +- .../models/ExperimentRetrieveParamsTest.kt | 23 +- .../models/ExperimentSummarizeParamsTest.kt | 57 +- .../api/models/ExperimentTest.kt | 122 +- .../api/models/ExperimentUpdateParamsTest.kt | 179 +- .../api/models/FeedbackDatasetItemTest.kt | 40 +- .../api/models/FeedbackExperimentItemTest.kt | 62 +- .../api/models/FeedbackProjectLogsItemTest.kt | 62 +- .../api/models/FeedbackResponseSchemaTest.kt | 9 +- .../models/FetchDatasetEventsResponseTest.kt | 112 +- .../FetchExperimentEventsResponseTest.kt | 229 +- .../FetchProjectLogsEventsResponseTest.kt | 229 +- .../api/models/FunctionCreateParamsTest.kt | 533 +-- .../api/models/FunctionDeleteParamsTest.kt | 21 +- .../api/models/FunctionInvokeParamsTest.kt | 209 +- .../api/models/FunctionListParamsTest.kt | 82 +- .../api/models/FunctionReplaceParamsTest.kt | 533 +-- .../api/models/FunctionRetrieveParamsTest.kt | 21 +- .../braintrustdata/api/models/FunctionTest.kt | 366 +- .../api/models/FunctionUpdateParamsTest.kt | 439 +- .../api/models/GroupCreateParamsTest.kt | 57 +- .../api/models/GroupDeleteParamsTest.kt | 19 +- .../api/models/GroupListParamsTest.kt | 58 +- .../api/models/GroupReplaceParamsTest.kt | 57 +- .../api/models/GroupRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/GroupTest.kt | 45 +- .../api/models/GroupUpdateParamsTest.kt | 79 +- .../api/models/InsertDatasetEventTest.kt | 73 +- .../api/models/InsertEventsResponseTest.kt | 8 +- .../api/models/InsertExperimentEventTest.kt | 186 +- .../api/models/InsertProjectLogsEventTest.kt | 182 +- .../api/models/MetricSummaryTest.kt | 31 +- .../api/models/OnlineScoreConfigTest.kt | 42 +- .../models/OrganizationDeleteParamsTest.kt | 23 +- .../api/models/OrganizationListParamsTest.kt | 52 +- .../OrganizationMemberUpdateParamsTest.kt | 123 +- .../models/OrganizationRetrieveParamsTest.kt | 23 +- .../api/models/OrganizationTest.kt | 36 +- .../models/OrganizationUpdateParamsTest.kt | 75 +- .../PatchOrganizationMembersOutputTest.kt | 20 +- .../api/models/ProjectCreateParamsTest.kt | 28 +- .../api/models/ProjectDeleteParamsTest.kt | 19 +- .../api/models/ProjectListParamsTest.kt | 58 +- .../models/ProjectLogFeedbackParamsTest.kt | 157 +- .../api/models/ProjectLogFetchParamsTest.kt | 69 +- .../models/ProjectLogFetchPostParamsTest.kt | 75 +- .../api/models/ProjectLogInsertParamsTest.kt | 333 +- .../api/models/ProjectLogsEventTest.kt | 214 +- .../api/models/ProjectRetrieveParamsTest.kt | 21 +- .../api/models/ProjectScoreCategoryTest.kt | 11 +- .../api/models/ProjectScoreConfigTest.kt | 61 +- .../models/ProjectScoreCreateParamsTest.kt | 179 +- .../models/ProjectScoreDeleteParamsTest.kt | 23 +- .../api/models/ProjectScoreListParamsTest.kt | 82 +- .../models/ProjectScoreReplaceParamsTest.kt | 179 +- .../models/ProjectScoreRetrieveParamsTest.kt | 23 +- .../api/models/ProjectScoreTest.kt | 122 +- .../models/ProjectScoreUpdateParamsTest.kt | 184 +- .../api/models/ProjectSettingsTest.kt | 8 +- .../api/models/ProjectTagCreateParamsTest.kt | 58 +- .../api/models/ProjectTagDeleteParamsTest.kt | 23 +- .../api/models/ProjectTagListParamsTest.kt | 70 +- .../api/models/ProjectTagReplaceParamsTest.kt | 58 +- .../models/ProjectTagRetrieveParamsTest.kt | 23 +- .../api/models/ProjectTagTest.kt | 35 +- .../api/models/ProjectTagUpdateParamsTest.kt | 67 +- .../braintrustdata/api/models/ProjectTest.kt | 40 +- .../api/models/ProjectUpdateParamsTest.kt | 64 +- .../api/models/PromptCreateParamsTest.kt | 419 +- .../api/models/PromptDataTest.kt | 227 +- .../api/models/PromptDeleteParamsTest.kt | 19 +- .../api/models/PromptListParamsTest.kt | 82 +- .../api/models/PromptOptionsTest.kt | 104 +- .../api/models/PromptReplaceParamsTest.kt | 419 +- .../api/models/PromptRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/PromptTest.kt | 301 +- .../api/models/PromptUpdateParamsTest.kt | 414 +- .../braintrustdata/api/models/RepoInfoTest.kt | 43 +- .../api/models/RoleCreateParamsTest.kt | 90 +- .../api/models/RoleDeleteParamsTest.kt | 19 +- .../api/models/RoleListParamsTest.kt | 58 +- .../api/models/RoleReplaceParamsTest.kt | 90 +- .../api/models/RoleRetrieveParamsTest.kt | 19 +- .../com/braintrustdata/api/models/RoleTest.kt | 60 +- .../api/models/RoleUpdateParamsTest.kt | 144 +- .../api/models/ScoreSummaryTest.kt | 27 +- .../api/models/SpanAttributesTest.kt | 12 +- .../api/models/SpanIFrameTest.kt | 44 +- .../api/models/SpanIframeCreateParamsTest.kt | 72 +- .../api/models/SpanIframeDeleteParamsTest.kt | 23 +- .../api/models/SpanIframeListParamsTest.kt | 58 +- .../api/models/SpanIframeReplaceParamsTest.kt | 72 +- .../models/SpanIframeRetrieveParamsTest.kt | 23 +- .../api/models/SpanIframeUpdateParamsTest.kt | 67 +- .../models/SummarizeDatasetResponseTest.kt | 32 +- .../models/SummarizeExperimentResponseTest.kt | 134 +- .../models/TopLevelHelloWorldParamsTest.kt | 2 +- .../api/models/UserListParamsTest.kt | 70 +- .../api/models/UserRetrieveParamsTest.kt | 19 +- .../com/braintrustdata/api/models/UserTest.kt | 31 +- .../api/models/ViewCreateParamsTest.kt | 208 +- .../api/models/ViewDataSearchTest.kt | 26 +- .../braintrustdata/api/models/ViewDataTest.kt | 36 +- .../api/models/ViewDeleteParamsTest.kt | 69 +- .../api/models/ViewListParamsTest.kt | 81 +- .../api/models/ViewOptionsTest.kt | 45 +- .../api/models/ViewReplaceParamsTest.kt | 208 +- .../api/models/ViewRetrieveParamsTest.kt | 69 +- .../com/braintrustdata/api/models/ViewTest.kt | 129 +- .../api/models/ViewUpdateParamsTest.kt | 221 +- .../api/services/ErrorHandlingTest.kt | 343 +- .../api/services/ServiceParamsTest.kt | 45 +- .../api/services/async/AclServiceAsyncTest.kt | 232 +- .../async/AiSecretServiceAsyncTest.kt | 227 +- .../services/async/ApiKeyServiceAsyncTest.kt | 89 +- .../services/async/DatasetServiceAsyncTest.kt | 374 +- .../services/async/EnvVarServiceAsyncTest.kt | 192 +- .../services/async/EvalServiceAsyncTest.kt | 106 +- .../async/ExperimentServiceAsyncTest.kt | 510 +-- .../async/FunctionServiceAsyncTest.kt | 664 ++- .../services/async/GroupServiceAsyncTest.kt | 184 +- .../async/OrganizationServiceAsyncTest.kt | 100 +- .../async/ProjectScoreServiceAsyncTest.kt | 293 +- .../services/async/ProjectServiceAsyncTest.kt | 135 +- .../async/ProjectTagServiceAsyncTest.kt | 176 +- .../services/async/PromptServiceAsyncTest.kt | 537 +-- .../services/async/RoleServiceAsyncTest.kt | 223 +- .../async/SpanIframeServiceAsyncTest.kt | 180 +- .../async/TopLevelServiceAsyncTest.kt | 16 +- .../services/async/UserServiceAsyncTest.kt | 44 +- .../services/async/ViewServiceAsyncTest.kt | 340 +- .../organizations/MemberServiceAsyncTest.kt | 56 +- .../async/projects/LogServiceAsyncTest.kt | 240 +- .../api/services/blocking/AclServiceTest.kt | 220 +- .../services/blocking/AiSecretServiceTest.kt | 213 +- .../services/blocking/ApiKeyServiceTest.kt | 81 +- .../services/blocking/DatasetServiceTest.kt | 354 +- .../services/blocking/EnvVarServiceTest.kt | 180 +- .../api/services/blocking/EvalServiceTest.kt | 104 +- .../blocking/ExperimentServiceTest.kt | 490 +- .../services/blocking/FunctionServiceTest.kt | 650 +-- .../api/services/blocking/GroupServiceTest.kt | 172 +- .../blocking/OrganizationServiceTest.kt | 92 +- .../blocking/ProjectScoreServiceTest.kt | 281 +- .../services/blocking/ProjectServiceTest.kt | 125 +- .../blocking/ProjectTagServiceTest.kt | 164 +- .../services/blocking/PromptServiceTest.kt | 517 +-- .../api/services/blocking/RoleServiceTest.kt | 211 +- .../blocking/SpanIframeServiceTest.kt | 168 +- .../services/blocking/TopLevelServiceTest.kt | 14 +- .../api/services/blocking/UserServiceTest.kt | 40 +- .../api/services/blocking/ViewServiceTest.kt | 328 +- .../organizations/MemberServiceTest.kt | 54 +- .../blocking/projects/LogServiceTest.kt | 232 +- 539 files changed, 77745 insertions(+), 71080 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 94c291ac..84c8fb9c 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -19,10 +19,15 @@ class BraintrustOkHttpClient private constructor() { companion object { - /** Returns a mutable builder for constructing an instance of [BraintrustOkHttpClient]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [BraintrustOkHttpClient]. + */ + @JvmStatic + fun builder() = Builder() - @JvmStatic fun fromEnv(): BraintrustClient = builder().fromEnv().build() + @JvmStatic + fun fromEnv(): BraintrustClient = builder().fromEnv().build() } /** A builder for [BraintrustOkHttpClient]. */ @@ -33,99 +38,163 @@ class BraintrustOkHttpClient private constructor() { private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } - - fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } - - fun clock(clock: Clock) = apply { clientOptions.clock(clock) } - - fun headers(headers: Headers) = apply { clientOptions.headers(headers) } - - fun headers(headers: Map>) = apply { - clientOptions.headers(headers) - } - - fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } - - fun putHeaders(name: String, values: Iterable) = apply { - clientOptions.putHeaders(name, values) - } - - fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } - - fun putAllHeaders(headers: Map>) = apply { - clientOptions.putAllHeaders(headers) - } - - fun replaceHeaders(name: String, value: String) = apply { - clientOptions.replaceHeaders(name, value) - } - - fun replaceHeaders(name: String, values: Iterable) = apply { - clientOptions.replaceHeaders(name, values) - } - - fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } - - fun replaceAllHeaders(headers: Map>) = apply { - clientOptions.replaceAllHeaders(headers) - } - - fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } - - fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } - - fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } - - fun queryParams(queryParams: Map>) = apply { - clientOptions.queryParams(queryParams) - } - - fun putQueryParam(key: String, value: String) = apply { - clientOptions.putQueryParam(key, value) - } - - fun putQueryParams(key: String, values: Iterable) = apply { - clientOptions.putQueryParams(key, values) - } - - fun putAllQueryParams(queryParams: QueryParams) = apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun putAllQueryParams(queryParams: Map>) = apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun replaceQueryParams(key: String, value: String) = apply { - clientOptions.replaceQueryParams(key, value) - } - - fun replaceQueryParams(key: String, values: Iterable) = apply { - clientOptions.replaceQueryParams(key, values) - } - - fun replaceAllQueryParams(queryParams: QueryParams) = apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun replaceAllQueryParams(queryParams: Map>) = apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } - - fun removeAllQueryParams(keys: Set) = apply { - clientOptions.removeAllQueryParams(keys) - } - - fun timeout(timeout: Timeout) = apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } + fun baseUrl(baseUrl: String) = + apply { + clientOptions.baseUrl(baseUrl) + this.baseUrl = baseUrl + } + + fun jsonMapper(jsonMapper: JsonMapper) = + apply { + clientOptions.jsonMapper(jsonMapper) + } + + fun clock(clock: Clock) = + apply { + clientOptions.clock(clock) + } + + fun headers(headers: Headers) = + apply { + clientOptions.headers(headers) + } + + fun headers(headers: Map>) = + apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = + apply { + clientOptions.putHeader( + name, value + ) + } + + fun putHeaders(name: String, values: Iterable) = + apply { + clientOptions.putHeaders( + name, values + ) + } + + fun putAllHeaders(headers: Headers) = + apply { + clientOptions.putAllHeaders(headers) + } + + fun putAllHeaders(headers: Map>) = + apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = + apply { + clientOptions.replaceHeaders( + name, value + ) + } + + fun replaceHeaders(name: String, values: Iterable) = + apply { + clientOptions.replaceHeaders( + name, values + ) + } + + fun replaceAllHeaders(headers: Headers) = + apply { + clientOptions.replaceAllHeaders(headers) + } + + fun replaceAllHeaders(headers: Map>) = + apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = + apply { + clientOptions.removeHeaders(name) + } + + fun removeAllHeaders(names: Set) = + apply { + clientOptions.removeAllHeaders(names) + } + + fun queryParams(queryParams: QueryParams) = + apply { + clientOptions.queryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = + apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = + apply { + clientOptions.putQueryParam( + key, value + ) + } + + fun putQueryParams(key: String, values: Iterable) = + apply { + clientOptions.putQueryParams( + key, values + ) + } + + fun putAllQueryParams(queryParams: QueryParams) = + apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = + apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = + apply { + clientOptions.replaceQueryParams( + key, value + ) + } + + fun replaceQueryParams(key: String, values: Iterable) = + apply { + clientOptions.replaceQueryParams( + key, values + ) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = + apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = + apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = + apply { + clientOptions.removeQueryParams(key) + } + + fun removeAllQueryParams(keys: Set) = + apply { + clientOptions.removeAllQueryParams(keys) + } + + fun timeout(timeout: Timeout) = + apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } /** * Sets the maximum time allowed for a complete HTTP call, not including retries. @@ -136,31 +205,40 @@ class BraintrustOkHttpClient private constructor() { */ fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + fun maxRetries(maxRetries: Int) = + apply { + clientOptions.maxRetries(maxRetries) + } - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } + fun proxy(proxy: Proxy) = + apply { + this.proxy = proxy + } - fun responseValidation(responseValidation: Boolean) = apply { - clientOptions.responseValidation(responseValidation) - } + fun responseValidation(responseValidation: Boolean) = + apply { + clientOptions.responseValidation(responseValidation) + } - fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: String?) = + apply { + clientOptions.apiKey(apiKey) + } fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) - fun fromEnv() = apply { clientOptions.fromEnv() } + fun fromEnv() = + apply { + clientOptions.fromEnv() + } fun build(): BraintrustClient = - BraintrustClientImpl( - clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(baseUrl) - .timeout(timeout) - .proxy(proxy) - .build() - ) - .build() - ) + BraintrustClientImpl(clientOptions + .httpClient(OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build()) + .build()) } } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index ffc88f5c..51d97cb3 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -20,11 +20,14 @@ class BraintrustOkHttpClientAsync private constructor() { companion object { /** - * Returns a mutable builder for constructing an instance of [BraintrustOkHttpClientAsync]. + * Returns a mutable builder for constructing an instance of + * [BraintrustOkHttpClientAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() - @JvmStatic fun fromEnv(): BraintrustClientAsync = builder().fromEnv().build() + @JvmStatic + fun fromEnv(): BraintrustClientAsync = builder().fromEnv().build() } /** A builder for [BraintrustOkHttpClientAsync]. */ @@ -35,99 +38,163 @@ class BraintrustOkHttpClientAsync private constructor() { private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } - - fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } - - fun clock(clock: Clock) = apply { clientOptions.clock(clock) } - - fun headers(headers: Headers) = apply { clientOptions.headers(headers) } - - fun headers(headers: Map>) = apply { - clientOptions.headers(headers) - } - - fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } - - fun putHeaders(name: String, values: Iterable) = apply { - clientOptions.putHeaders(name, values) - } - - fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } - - fun putAllHeaders(headers: Map>) = apply { - clientOptions.putAllHeaders(headers) - } - - fun replaceHeaders(name: String, value: String) = apply { - clientOptions.replaceHeaders(name, value) - } - - fun replaceHeaders(name: String, values: Iterable) = apply { - clientOptions.replaceHeaders(name, values) - } - - fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } - - fun replaceAllHeaders(headers: Map>) = apply { - clientOptions.replaceAllHeaders(headers) - } - - fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } - - fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } - - fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } - - fun queryParams(queryParams: Map>) = apply { - clientOptions.queryParams(queryParams) - } - - fun putQueryParam(key: String, value: String) = apply { - clientOptions.putQueryParam(key, value) - } - - fun putQueryParams(key: String, values: Iterable) = apply { - clientOptions.putQueryParams(key, values) - } - - fun putAllQueryParams(queryParams: QueryParams) = apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun putAllQueryParams(queryParams: Map>) = apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun replaceQueryParams(key: String, value: String) = apply { - clientOptions.replaceQueryParams(key, value) - } - - fun replaceQueryParams(key: String, values: Iterable) = apply { - clientOptions.replaceQueryParams(key, values) - } - - fun replaceAllQueryParams(queryParams: QueryParams) = apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun replaceAllQueryParams(queryParams: Map>) = apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } - - fun removeAllQueryParams(keys: Set) = apply { - clientOptions.removeAllQueryParams(keys) - } - - fun timeout(timeout: Timeout) = apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } + fun baseUrl(baseUrl: String) = + apply { + clientOptions.baseUrl(baseUrl) + this.baseUrl = baseUrl + } + + fun jsonMapper(jsonMapper: JsonMapper) = + apply { + clientOptions.jsonMapper(jsonMapper) + } + + fun clock(clock: Clock) = + apply { + clientOptions.clock(clock) + } + + fun headers(headers: Headers) = + apply { + clientOptions.headers(headers) + } + + fun headers(headers: Map>) = + apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = + apply { + clientOptions.putHeader( + name, value + ) + } + + fun putHeaders(name: String, values: Iterable) = + apply { + clientOptions.putHeaders( + name, values + ) + } + + fun putAllHeaders(headers: Headers) = + apply { + clientOptions.putAllHeaders(headers) + } + + fun putAllHeaders(headers: Map>) = + apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = + apply { + clientOptions.replaceHeaders( + name, value + ) + } + + fun replaceHeaders(name: String, values: Iterable) = + apply { + clientOptions.replaceHeaders( + name, values + ) + } + + fun replaceAllHeaders(headers: Headers) = + apply { + clientOptions.replaceAllHeaders(headers) + } + + fun replaceAllHeaders(headers: Map>) = + apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = + apply { + clientOptions.removeHeaders(name) + } + + fun removeAllHeaders(names: Set) = + apply { + clientOptions.removeAllHeaders(names) + } + + fun queryParams(queryParams: QueryParams) = + apply { + clientOptions.queryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = + apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = + apply { + clientOptions.putQueryParam( + key, value + ) + } + + fun putQueryParams(key: String, values: Iterable) = + apply { + clientOptions.putQueryParams( + key, values + ) + } + + fun putAllQueryParams(queryParams: QueryParams) = + apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = + apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = + apply { + clientOptions.replaceQueryParams( + key, value + ) + } + + fun replaceQueryParams(key: String, values: Iterable) = + apply { + clientOptions.replaceQueryParams( + key, values + ) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = + apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = + apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = + apply { + clientOptions.removeQueryParams(key) + } + + fun removeAllQueryParams(keys: Set) = + apply { + clientOptions.removeAllQueryParams(keys) + } + + fun timeout(timeout: Timeout) = + apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } /** * Sets the maximum time allowed for a complete HTTP call, not including retries. @@ -138,31 +205,40 @@ class BraintrustOkHttpClientAsync private constructor() { */ fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + fun maxRetries(maxRetries: Int) = + apply { + clientOptions.maxRetries(maxRetries) + } - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } + fun proxy(proxy: Proxy) = + apply { + this.proxy = proxy + } - fun responseValidation(responseValidation: Boolean) = apply { - clientOptions.responseValidation(responseValidation) - } + fun responseValidation(responseValidation: Boolean) = + apply { + clientOptions.responseValidation(responseValidation) + } - fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: String?) = + apply { + clientOptions.apiKey(apiKey) + } fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) - fun fromEnv() = apply { clientOptions.fromEnv() } + fun fromEnv() = + apply { + clientOptions.fromEnv() + } fun build(): BraintrustClientAsync = - BraintrustClientAsyncImpl( - clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(baseUrl) - .timeout(timeout) - .proxy(proxy) - .build() - ) - .build() - ) + BraintrustClientAsyncImpl(clientOptions + .httpClient(OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build()) + .build()) } } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index 49a5df68..fff41a7f 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -5,26 +5,27 @@ import com.braintrustdata.api.core.Timeout import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpClient -import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpRequestBody import com.braintrustdata.api.core.http.HttpResponse +import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.errors.BraintrustIoException import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.CompletableFuture +import java.util.concurrent.TimeUnit import okhttp3.Call import okhttp3.Callback import okhttp3.HttpUrl -import okhttp3.HttpUrl.Companion.toHttpUrl -import okhttp3.MediaType -import okhttp3.MediaType.Companion.toMediaType +import okhttp3.Response import okhttp3.Request import okhttp3.RequestBody +import okhttp3.MediaType +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType.Companion.toMediaType import okhttp3.RequestBody.Companion.toRequestBody -import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink @@ -32,7 +33,10 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { val call = newCall(request, requestOptions) return try { @@ -52,18 +56,16 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val request.body?.run { future.whenComplete { _, _ -> close() } } - newCall(request, requestOptions) - .enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + newCall(request, requestOptions).enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(BraintrustIoException("Request failed", e)) - } + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(BraintrustIoException("Request failed", e)) } - ) + }) return future } @@ -85,7 +87,11 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } if (logLevel != null) { clientBuilder.addNetworkInterceptor( - HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } + HttpLoggingInterceptor() + .setLevel(logLevel) + .apply { + redactHeader("Authorization") + } ) } @@ -112,18 +118,16 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val headers.values(name).forEach { builder.header(name, it) } } - if ( - !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 - ) { + if (!headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0) { builder.header( "X-Stainless-Read-Timeout", - Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString() ) } if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { builder.header( "X-Stainless-Timeout", - Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString() ) } @@ -183,9 +187,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } private fun okhttp3.Headers.toHeaders(): Headers { - val headersBuilder = Headers.builder() - forEach { (name, value) -> headersBuilder.put(name, value) } - return headersBuilder.build() + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt index bc327480..98b6a055 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt @@ -23,31 +23,33 @@ import com.braintrustdata.api.services.blocking.UserService import com.braintrustdata.api.services.blocking.ViewService /** - * A client for interacting with the Braintrust REST API synchronously. You can also switch to - * asynchronous execution via the [async] method. + * A client for interacting with the Braintrust REST API synchronously. You can + * also switch to asynchronous execution via the [async] method. * - * This client performs best when you create a single instance and reuse it for all interactions - * with the REST API. This is because each client holds its own connection pool and thread pools. - * Reusing connections and threads reduces latency and saves memory. The client also handles rate - * limiting per client. This means that creating and using multiple instances at the same time will - * not respect rate limits. + * This client performs best when you create a single instance and reuse it for all + * interactions with the REST API. This is because each client holds its own + * connection pool and thread pools. Reusing connections and threads reduces + * latency and saves memory. The client also handles rate limiting per client. This + * means that creating and using multiple instances at the same time will not + * respect rate limits. * - * The threads and connections that are held will be released automatically if they remain idle. But - * if you are writing an application that needs to aggressively release unused resources, then you - * may call [close]. + * The threads and connections that are held will be released automatically if they + * remain idle. But if you are writing an application that needs to aggressively + * release unused resources, then you may call [close]. */ interface BraintrustClient { /** * Returns a version of this client that uses asynchronous execution. * - * The returned client shares its resources, like its connection pool and thread pools, with - * this client. + * The returned client shares its resources, like its connection pool and thread + * pools, with this client. */ fun async(): BraintrustClientAsync /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -92,17 +94,21 @@ interface BraintrustClient { /** * Closes this client, relinquishing any underlying resources. * - * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and - * usually should not be synchronously closed via try-with-resources. + * This is purposefully not inherited from [AutoCloseable] because the client is + * long-lived and usually should not be synchronously closed via + * try-with-resources. * - * It's also usually not necessary to call this method at all. the default HTTP client - * automatically releases threads and connections if they remain idle, but if you are writing an - * application that needs to aggressively release unused resources, then you may call this - * method. + * It's also usually not necessary to call this method at all. the default HTTP + * client automatically releases threads and connections if they remain idle, but + * if you are writing an application that needs to aggressively release unused + * resources, then you may call this method. */ fun close() - /** A view of [BraintrustClient] that provides access to raw HTTP responses for each method. */ + /** + * A view of [BraintrustClient] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { fun topLevel(): TopLevelService.WithRawResponse diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt index 24ed3368..56e174fe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt @@ -23,31 +23,33 @@ import com.braintrustdata.api.services.async.UserServiceAsync import com.braintrustdata.api.services.async.ViewServiceAsync /** - * A client for interacting with the Braintrust REST API asynchronously. You can also switch to - * synchronous execution via the [sync] method. + * A client for interacting with the Braintrust REST API asynchronously. You can + * also switch to synchronous execution via the [sync] method. * - * This client performs best when you create a single instance and reuse it for all interactions - * with the REST API. This is because each client holds its own connection pool and thread pools. - * Reusing connections and threads reduces latency and saves memory. The client also handles rate - * limiting per client. This means that creating and using multiple instances at the same time will - * not respect rate limits. + * This client performs best when you create a single instance and reuse it for all + * interactions with the REST API. This is because each client holds its own + * connection pool and thread pools. Reusing connections and threads reduces + * latency and saves memory. The client also handles rate limiting per client. This + * means that creating and using multiple instances at the same time will not + * respect rate limits. * - * The threads and connections that are held will be released automatically if they remain idle. But - * if you are writing an application that needs to aggressively release unused resources, then you - * may call [close]. + * The threads and connections that are held will be released automatically if they + * remain idle. But if you are writing an application that needs to aggressively + * release unused resources, then you may call [close]. */ interface BraintrustClientAsync { /** * Returns a version of this client that uses synchronous execution. * - * The returned client shares its resources, like its connection pool and thread pools, with - * this client. + * The returned client shares its resources, like its connection pool and thread + * pools, with this client. */ fun sync(): BraintrustClient /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -92,18 +94,20 @@ interface BraintrustClientAsync { /** * Closes this client, relinquishing any underlying resources. * - * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and - * usually should not be synchronously closed via try-with-resources. + * This is purposefully not inherited from [AutoCloseable] because the client is + * long-lived and usually should not be synchronously closed via + * try-with-resources. * - * It's also usually not necessary to call this method at all. the default HTTP client - * automatically releases threads and connections if they remain idle, but if you are writing an - * application that needs to aggressively release unused resources, then you may call this - * method. + * It's also usually not necessary to call this method at all. the default HTTP + * client automatically releases threads and connections if they remain idle, but + * if you are writing an application that needs to aggressively release unused + * resources, then you may call this method. */ fun close() /** - * A view of [BraintrustClientAsync] that provides access to raw HTTP responses for each method. + * A view of [BraintrustClientAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index e945466b..87e33418 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -43,86 +43,57 @@ import com.braintrustdata.api.services.async.UserServiceAsyncImpl import com.braintrustdata.api.services.async.ViewServiceAsync import com.braintrustdata.api.services.async.ViewServiceAsyncImpl -class BraintrustClientAsyncImpl(private val clientOptions: ClientOptions) : BraintrustClientAsync { +class BraintrustClientAsyncImpl( + private val clientOptions: ClientOptions, + +) : BraintrustClientAsync { private val clientOptionsWithUserAgent = - if (clientOptions.headers.names().contains("User-Agent")) clientOptions - else - clientOptions - .toBuilder() - .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") - .build() + + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + + else clientOptions.toBuilder().putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}").build() // Pass the original clientOptions so that this client sets its own User-Agent. private val sync: BraintrustClient by lazy { BraintrustClientImpl(clientOptions) } - private val withRawResponse: BraintrustClientAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } + private val withRawResponse: BraintrustClientAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - private val topLevel: TopLevelServiceAsync by lazy { - TopLevelServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val topLevel: TopLevelServiceAsync by lazy { TopLevelServiceAsyncImpl(clientOptionsWithUserAgent) } - private val projects: ProjectServiceAsync by lazy { - ProjectServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptionsWithUserAgent) } - private val experiments: ExperimentServiceAsync by lazy { - ExperimentServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val experiments: ExperimentServiceAsync by lazy { ExperimentServiceAsyncImpl(clientOptionsWithUserAgent) } - private val datasets: DatasetServiceAsync by lazy { - DatasetServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptionsWithUserAgent) } - private val prompts: PromptServiceAsync by lazy { - PromptServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val prompts: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptionsWithUserAgent) } private val roles: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptionsWithUserAgent) } - private val groups: GroupServiceAsync by lazy { - GroupServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val groups: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptionsWithUserAgent) } private val acls: AclServiceAsync by lazy { AclServiceAsyncImpl(clientOptionsWithUserAgent) } private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptionsWithUserAgent) } - private val projectScores: ProjectScoreServiceAsync by lazy { - ProjectScoreServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val projectScores: ProjectScoreServiceAsync by lazy { ProjectScoreServiceAsyncImpl(clientOptionsWithUserAgent) } - private val projectTags: ProjectTagServiceAsync by lazy { - ProjectTagServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val projectTags: ProjectTagServiceAsync by lazy { ProjectTagServiceAsyncImpl(clientOptionsWithUserAgent) } - private val spanIframes: SpanIframeServiceAsync by lazy { - SpanIframeServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val spanIframes: SpanIframeServiceAsync by lazy { SpanIframeServiceAsyncImpl(clientOptionsWithUserAgent) } - private val functions: FunctionServiceAsync by lazy { - FunctionServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val functions: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptionsWithUserAgent) } private val views: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptionsWithUserAgent) } - private val organizations: OrganizationServiceAsync by lazy { - OrganizationServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val organizations: OrganizationServiceAsync by lazy { OrganizationServiceAsyncImpl(clientOptionsWithUserAgent) } - private val apiKeys: ApiKeyServiceAsync by lazy { - ApiKeyServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val apiKeys: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptionsWithUserAgent) } - private val aiSecrets: AiSecretServiceAsync by lazy { - AiSecretServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val aiSecrets: AiSecretServiceAsync by lazy { AiSecretServiceAsyncImpl(clientOptionsWithUserAgent) } - private val envVars: EnvVarServiceAsync by lazy { - EnvVarServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val envVars: EnvVarServiceAsync by lazy { EnvVarServiceAsyncImpl(clientOptionsWithUserAgent) } private val evals: EvalServiceAsync by lazy { EvalServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -170,84 +141,48 @@ class BraintrustClientAsyncImpl(private val clientOptions: ClientOptions) : Brai override fun close() = clientOptions.httpClient.close() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BraintrustClientAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : BraintrustClientAsync.WithRawResponse { - private val topLevel: TopLevelServiceAsync.WithRawResponse by lazy { - TopLevelServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val topLevel: TopLevelServiceAsync.WithRawResponse by lazy { TopLevelServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val projects: ProjectServiceAsync.WithRawResponse by lazy { - ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val projects: ProjectServiceAsync.WithRawResponse by lazy { ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val experiments: ExperimentServiceAsync.WithRawResponse by lazy { - ExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val experiments: ExperimentServiceAsync.WithRawResponse by lazy { ExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val datasets: DatasetServiceAsync.WithRawResponse by lazy { - DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val datasets: DatasetServiceAsync.WithRawResponse by lazy { DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val prompts: PromptServiceAsync.WithRawResponse by lazy { - PromptServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val prompts: PromptServiceAsync.WithRawResponse by lazy { PromptServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val roles: RoleServiceAsync.WithRawResponse by lazy { - RoleServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val roles: RoleServiceAsync.WithRawResponse by lazy { RoleServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val groups: GroupServiceAsync.WithRawResponse by lazy { - GroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val groups: GroupServiceAsync.WithRawResponse by lazy { GroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val acls: AclServiceAsync.WithRawResponse by lazy { - AclServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val acls: AclServiceAsync.WithRawResponse by lazy { AclServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val users: UserServiceAsync.WithRawResponse by lazy { - UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val users: UserServiceAsync.WithRawResponse by lazy { UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val projectScores: ProjectScoreServiceAsync.WithRawResponse by lazy { - ProjectScoreServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val projectScores: ProjectScoreServiceAsync.WithRawResponse by lazy { ProjectScoreServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val projectTags: ProjectTagServiceAsync.WithRawResponse by lazy { - ProjectTagServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val projectTags: ProjectTagServiceAsync.WithRawResponse by lazy { ProjectTagServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val spanIframes: SpanIframeServiceAsync.WithRawResponse by lazy { - SpanIframeServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val spanIframes: SpanIframeServiceAsync.WithRawResponse by lazy { SpanIframeServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val functions: FunctionServiceAsync.WithRawResponse by lazy { - FunctionServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val functions: FunctionServiceAsync.WithRawResponse by lazy { FunctionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val views: ViewServiceAsync.WithRawResponse by lazy { - ViewServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val views: ViewServiceAsync.WithRawResponse by lazy { ViewServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val organizations: OrganizationServiceAsync.WithRawResponse by lazy { - OrganizationServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val organizations: OrganizationServiceAsync.WithRawResponse by lazy { OrganizationServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val apiKeys: ApiKeyServiceAsync.WithRawResponse by lazy { - ApiKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val apiKeys: ApiKeyServiceAsync.WithRawResponse by lazy { ApiKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val aiSecrets: AiSecretServiceAsync.WithRawResponse by lazy { - AiSecretServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val aiSecrets: AiSecretServiceAsync.WithRawResponse by lazy { AiSecretServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val envVars: EnvVarServiceAsync.WithRawResponse by lazy { - EnvVarServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val envVars: EnvVarServiceAsync.WithRawResponse by lazy { EnvVarServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val evals: EvalServiceAsync.WithRawResponse by lazy { - EvalServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val evals: EvalServiceAsync.WithRawResponse by lazy { EvalServiceAsyncImpl.WithRawResponseImpl(clientOptions) } override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index 3eecd3cb..ef76e148 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -43,32 +43,27 @@ import com.braintrustdata.api.services.blocking.UserServiceImpl import com.braintrustdata.api.services.blocking.ViewService import com.braintrustdata.api.services.blocking.ViewServiceImpl -class BraintrustClientImpl(private val clientOptions: ClientOptions) : BraintrustClient { +class BraintrustClientImpl( + private val clientOptions: ClientOptions, + +) : BraintrustClient { private val clientOptionsWithUserAgent = - if (clientOptions.headers.names().contains("User-Agent")) clientOptions - else - clientOptions - .toBuilder() - .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") - .build() + + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + + else clientOptions.toBuilder().putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}").build() // Pass the original clientOptions so that this client sets its own User-Agent. private val async: BraintrustClientAsync by lazy { BraintrustClientAsyncImpl(clientOptions) } - private val withRawResponse: BraintrustClient.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } + private val withRawResponse: BraintrustClient.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - private val topLevel: TopLevelService by lazy { - TopLevelServiceImpl(clientOptionsWithUserAgent) - } + private val topLevel: TopLevelService by lazy { TopLevelServiceImpl(clientOptionsWithUserAgent) } private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptionsWithUserAgent) } - private val experiments: ExperimentService by lazy { - ExperimentServiceImpl(clientOptionsWithUserAgent) - } + private val experiments: ExperimentService by lazy { ExperimentServiceImpl(clientOptionsWithUserAgent) } private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptionsWithUserAgent) } @@ -82,33 +77,21 @@ class BraintrustClientImpl(private val clientOptions: ClientOptions) : Braintrus private val users: UserService by lazy { UserServiceImpl(clientOptionsWithUserAgent) } - private val projectScores: ProjectScoreService by lazy { - ProjectScoreServiceImpl(clientOptionsWithUserAgent) - } + private val projectScores: ProjectScoreService by lazy { ProjectScoreServiceImpl(clientOptionsWithUserAgent) } - private val projectTags: ProjectTagService by lazy { - ProjectTagServiceImpl(clientOptionsWithUserAgent) - } + private val projectTags: ProjectTagService by lazy { ProjectTagServiceImpl(clientOptionsWithUserAgent) } - private val spanIframes: SpanIframeService by lazy { - SpanIframeServiceImpl(clientOptionsWithUserAgent) - } + private val spanIframes: SpanIframeService by lazy { SpanIframeServiceImpl(clientOptionsWithUserAgent) } - private val functions: FunctionService by lazy { - FunctionServiceImpl(clientOptionsWithUserAgent) - } + private val functions: FunctionService by lazy { FunctionServiceImpl(clientOptionsWithUserAgent) } private val views: ViewService by lazy { ViewServiceImpl(clientOptionsWithUserAgent) } - private val organizations: OrganizationService by lazy { - OrganizationServiceImpl(clientOptionsWithUserAgent) - } + private val organizations: OrganizationService by lazy { OrganizationServiceImpl(clientOptionsWithUserAgent) } private val apiKeys: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptionsWithUserAgent) } - private val aiSecrets: AiSecretService by lazy { - AiSecretServiceImpl(clientOptionsWithUserAgent) - } + private val aiSecrets: AiSecretService by lazy { AiSecretServiceImpl(clientOptionsWithUserAgent) } private val envVars: EnvVarService by lazy { EnvVarServiceImpl(clientOptionsWithUserAgent) } @@ -158,84 +141,48 @@ class BraintrustClientImpl(private val clientOptions: ClientOptions) : Braintrus override fun close() = clientOptions.httpClient.close() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BraintrustClient.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : BraintrustClient.WithRawResponse { - private val topLevel: TopLevelService.WithRawResponse by lazy { - TopLevelServiceImpl.WithRawResponseImpl(clientOptions) - } + private val topLevel: TopLevelService.WithRawResponse by lazy { TopLevelServiceImpl.WithRawResponseImpl(clientOptions) } - private val projects: ProjectService.WithRawResponse by lazy { - ProjectServiceImpl.WithRawResponseImpl(clientOptions) - } + private val projects: ProjectService.WithRawResponse by lazy { ProjectServiceImpl.WithRawResponseImpl(clientOptions) } - private val experiments: ExperimentService.WithRawResponse by lazy { - ExperimentServiceImpl.WithRawResponseImpl(clientOptions) - } + private val experiments: ExperimentService.WithRawResponse by lazy { ExperimentServiceImpl.WithRawResponseImpl(clientOptions) } - private val datasets: DatasetService.WithRawResponse by lazy { - DatasetServiceImpl.WithRawResponseImpl(clientOptions) - } + private val datasets: DatasetService.WithRawResponse by lazy { DatasetServiceImpl.WithRawResponseImpl(clientOptions) } - private val prompts: PromptService.WithRawResponse by lazy { - PromptServiceImpl.WithRawResponseImpl(clientOptions) - } + private val prompts: PromptService.WithRawResponse by lazy { PromptServiceImpl.WithRawResponseImpl(clientOptions) } - private val roles: RoleService.WithRawResponse by lazy { - RoleServiceImpl.WithRawResponseImpl(clientOptions) - } + private val roles: RoleService.WithRawResponse by lazy { RoleServiceImpl.WithRawResponseImpl(clientOptions) } - private val groups: GroupService.WithRawResponse by lazy { - GroupServiceImpl.WithRawResponseImpl(clientOptions) - } + private val groups: GroupService.WithRawResponse by lazy { GroupServiceImpl.WithRawResponseImpl(clientOptions) } - private val acls: AclService.WithRawResponse by lazy { - AclServiceImpl.WithRawResponseImpl(clientOptions) - } + private val acls: AclService.WithRawResponse by lazy { AclServiceImpl.WithRawResponseImpl(clientOptions) } - private val users: UserService.WithRawResponse by lazy { - UserServiceImpl.WithRawResponseImpl(clientOptions) - } + private val users: UserService.WithRawResponse by lazy { UserServiceImpl.WithRawResponseImpl(clientOptions) } - private val projectScores: ProjectScoreService.WithRawResponse by lazy { - ProjectScoreServiceImpl.WithRawResponseImpl(clientOptions) - } + private val projectScores: ProjectScoreService.WithRawResponse by lazy { ProjectScoreServiceImpl.WithRawResponseImpl(clientOptions) } - private val projectTags: ProjectTagService.WithRawResponse by lazy { - ProjectTagServiceImpl.WithRawResponseImpl(clientOptions) - } + private val projectTags: ProjectTagService.WithRawResponse by lazy { ProjectTagServiceImpl.WithRawResponseImpl(clientOptions) } - private val spanIframes: SpanIframeService.WithRawResponse by lazy { - SpanIframeServiceImpl.WithRawResponseImpl(clientOptions) - } + private val spanIframes: SpanIframeService.WithRawResponse by lazy { SpanIframeServiceImpl.WithRawResponseImpl(clientOptions) } - private val functions: FunctionService.WithRawResponse by lazy { - FunctionServiceImpl.WithRawResponseImpl(clientOptions) - } + private val functions: FunctionService.WithRawResponse by lazy { FunctionServiceImpl.WithRawResponseImpl(clientOptions) } - private val views: ViewService.WithRawResponse by lazy { - ViewServiceImpl.WithRawResponseImpl(clientOptions) - } + private val views: ViewService.WithRawResponse by lazy { ViewServiceImpl.WithRawResponseImpl(clientOptions) } - private val organizations: OrganizationService.WithRawResponse by lazy { - OrganizationServiceImpl.WithRawResponseImpl(clientOptions) - } + private val organizations: OrganizationService.WithRawResponse by lazy { OrganizationServiceImpl.WithRawResponseImpl(clientOptions) } - private val apiKeys: ApiKeyService.WithRawResponse by lazy { - ApiKeyServiceImpl.WithRawResponseImpl(clientOptions) - } + private val apiKeys: ApiKeyService.WithRawResponse by lazy { ApiKeyServiceImpl.WithRawResponseImpl(clientOptions) } - private val aiSecrets: AiSecretService.WithRawResponse by lazy { - AiSecretServiceImpl.WithRawResponseImpl(clientOptions) - } + private val aiSecrets: AiSecretService.WithRawResponse by lazy { AiSecretServiceImpl.WithRawResponseImpl(clientOptions) } - private val envVars: EnvVarService.WithRawResponse by lazy { - EnvVarServiceImpl.WithRawResponseImpl(clientOptions) - } + private val envVars: EnvVarService.WithRawResponse by lazy { EnvVarServiceImpl.WithRawResponseImpl(clientOptions) } - private val evals: EvalService.WithRawResponse by lazy { - EvalServiceImpl.WithRawResponseImpl(clientOptions) - } + private val evals: EvalService.WithRawResponse by lazy { EvalServiceImpl.WithRawResponseImpl(clientOptions) } override fun topLevel(): TopLevelService.WithRawResponse = topLevel diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt index 64d8a5b3..a197b7fe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt @@ -13,13 +13,9 @@ import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer import kotlin.reflect.KClass -abstract class BaseDeserializer(type: KClass) : - StdDeserializer(type.java), ContextualDeserializer { +abstract class BaseDeserializer(type: KClass) : StdDeserializer(type.java), ContextualDeserializer { - override fun createContextual( - context: DeserializationContext, - property: BeanProperty?, - ): JsonDeserializer { + override fun createContextual(context: DeserializationContext, property: BeanProperty?): JsonDeserializer { return this } @@ -29,11 +25,7 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: TypeReference, - validate: (T) -> Unit = {}, - ): T? { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference, validate: (T) -> Unit = {}): T? { return try { readValue(treeAsTokens(node), type).apply(validate) } catch (e: JsonMappingException) { @@ -43,11 +35,7 @@ abstract class BaseDeserializer(type: KClass) : } } - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: JavaType, - validate: (T) -> Unit = {}, - ): T? { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType, validate: (T) -> Unit = {}): T? { return try { readValue(treeAsTokens(node), type).apply(validate) } catch (e: JsonMappingException) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 38dc1b87..4e3c5177 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -12,8 +12,7 @@ import java.time.Clock import java.util.Optional import kotlin.jvm.optionals.getOrNull -class ClientOptions -private constructor( +class ClientOptions private constructor( private val originalHttpClient: HttpClient, @get:JvmName("httpClient") val httpClient: HttpClient, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @@ -25,6 +24,7 @@ private constructor( @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, private val apiKey: String?, + ) { fun apiKey(): Optional = Optional.ofNullable(apiKey) @@ -39,13 +39,16 @@ private constructor( * Returns a mutable builder for constructing an instance of [ClientOptions]. * * The following fields are required: + * * ```java * .httpClient() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() - @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() + @JvmStatic + fun fromEnv(): ClientOptions = builder().fromEnv().build() } /** A builder for [ClientOptions]. */ @@ -63,160 +66,232 @@ private constructor( private var apiKey: String? = null @JvmSynthetic - internal fun from(clientOptions: ClientOptions) = apply { - httpClient = clientOptions.originalHttpClient - jsonMapper = clientOptions.jsonMapper - clock = clientOptions.clock - baseUrl = clientOptions.baseUrl - headers = clientOptions.headers.toBuilder() - queryParams = clientOptions.queryParams.toBuilder() - responseValidation = clientOptions.responseValidation - timeout = clientOptions.timeout - maxRetries = clientOptions.maxRetries - apiKey = clientOptions.apiKey - } + internal fun from(clientOptions: ClientOptions) = + apply { + httpClient = clientOptions.originalHttpClient + jsonMapper = clientOptions.jsonMapper + clock = clientOptions.clock + baseUrl = clientOptions.baseUrl + headers = clientOptions.headers.toBuilder() + queryParams = clientOptions.queryParams.toBuilder() + responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout + maxRetries = clientOptions.maxRetries + apiKey = clientOptions.apiKey + } - fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun httpClient(httpClient: HttpClient) = + apply { + this.httpClient = httpClient + } - fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + fun jsonMapper(jsonMapper: JsonMapper) = + apply { + this.jsonMapper = jsonMapper + } - fun clock(clock: Clock) = apply { this.clock = clock } + fun clock(clock: Clock) = + apply { + this.clock = clock + } - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun baseUrl(baseUrl: String) = + apply { + this.baseUrl = baseUrl + } - fun responseValidation(responseValidation: Boolean) = apply { - this.responseValidation = responseValidation - } + fun responseValidation(responseValidation: Boolean) = + apply { + this.responseValidation = responseValidation + } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = + apply { + this.timeout = timeout + } - fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + fun maxRetries(maxRetries: Int) = + apply { + this.maxRetries = maxRetries + } - fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } + fun apiKey(apiKey: String?) = + apply { + this.apiKey = apiKey + } fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) - fun headers(headers: Headers) = apply { - this.headers.clear() - putAllHeaders(headers) - } - - fun headers(headers: Map>) = apply { - this.headers.clear() - putAllHeaders(headers) - } + fun headers(headers: Headers) = + apply { + this.headers.clear() + putAllHeaders(headers) + } - fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + fun headers(headers: Map>) = + apply { + this.headers.clear() + putAllHeaders(headers) + } - fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + fun putHeader(name: String, value: String) = + apply { + headers.put(name, value) + } - fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } + fun putHeaders(name: String, values: Iterable) = + apply { + headers.put(name, values) + } - fun putAllHeaders(headers: Map>) = apply { - this.headers.putAll(headers) - } + fun putAllHeaders(headers: Headers) = + apply { + this.headers.putAll(headers) + } - fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + fun putAllHeaders(headers: Map>) = + apply { + this.headers.putAll(headers) + } - fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replace(name, values) - } + fun replaceHeaders(name: String, value: String) = + apply { + headers.replace(name, value) + } - fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + fun replaceHeaders(name: String, values: Iterable) = + apply { + headers.replace(name, values) + } - fun replaceAllHeaders(headers: Map>) = apply { - this.headers.replaceAll(headers) - } + fun replaceAllHeaders(headers: Headers) = + apply { + this.headers.replaceAll(headers) + } - fun removeHeaders(name: String) = apply { headers.remove(name) } + fun replaceAllHeaders(headers: Map>) = + apply { + this.headers.replaceAll(headers) + } - fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + fun removeHeaders(name: String) = + apply { + headers.remove(name) + } - fun queryParams(queryParams: QueryParams) = apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } + fun removeAllHeaders(names: Set) = + apply { + headers.removeAll(names) + } - fun queryParams(queryParams: Map>) = apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } + fun queryParams(queryParams: QueryParams) = + apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } - fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + fun queryParams(queryParams: Map>) = + apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } - fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.put(key, values) - } + fun putQueryParam(key: String, value: String) = + apply { + queryParams.put(key, value) + } - fun putAllQueryParams(queryParams: QueryParams) = apply { - this.queryParams.putAll(queryParams) - } + fun putQueryParams(key: String, values: Iterable) = + apply { + queryParams.put(key, values) + } - fun putAllQueryParams(queryParams: Map>) = apply { - this.queryParams.putAll(queryParams) - } + fun putAllQueryParams(queryParams: QueryParams) = + apply { + this.queryParams.putAll(queryParams) + } - fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replace(key, value) - } + fun putAllQueryParams(queryParams: Map>) = + apply { + this.queryParams.putAll(queryParams) + } - fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replace(key, values) - } + fun replaceQueryParams(key: String, value: String) = + apply { + queryParams.replace(key, value) + } - fun replaceAllQueryParams(queryParams: QueryParams) = apply { - this.queryParams.replaceAll(queryParams) - } + fun replaceQueryParams(key: String, values: Iterable) = + apply { + queryParams.replace(key, values) + } - fun replaceAllQueryParams(queryParams: Map>) = apply { - this.queryParams.replaceAll(queryParams) - } + fun replaceAllQueryParams(queryParams: QueryParams) = + apply { + this.queryParams.replaceAll(queryParams) + } - fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + fun replaceAllQueryParams(queryParams: Map>) = + apply { + this.queryParams.replaceAll(queryParams) + } - fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + fun removeQueryParams(key: String) = + apply { + queryParams.remove(key) + } - fun fromEnv() = apply { System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) } } + fun removeAllQueryParams(keys: Set) = + apply { + queryParams.removeAll(keys) + } - fun build(): ClientOptions { - val httpClient = checkRequired("httpClient", httpClient) - - val headers = Headers.builder() - val queryParams = QueryParams.builder() - headers.put("X-Stainless-Lang", "java") - headers.put("X-Stainless-Arch", getOsArch()) - headers.put("X-Stainless-OS", getOsName()) - headers.put("X-Stainless-OS-Version", getOsVersion()) - headers.put("X-Stainless-Package-Version", getPackageVersion()) - headers.put("X-Stainless-Runtime", "JRE") - headers.put("X-Stainless-Runtime-Version", getJavaVersion()) - apiKey?.let { - if (!it.isEmpty()) { - headers.put("Authorization", "Bearer $it") + fun fromEnv() = + apply { + System.getenv("BRAINTRUST_API_KEY")?.let { + apiKey(it) } } - headers.replaceAll(this.headers.build()) - queryParams.replaceAll(this.queryParams.build()) - - return ClientOptions( - httpClient, - PhantomReachableClosingHttpClient( - RetryingHttpClient.builder() - .httpClient(httpClient) - .clock(clock) - .maxRetries(maxRetries) - .build() - ), - jsonMapper, - clock, - baseUrl, - headers.build(), - queryParams.build(), - responseValidation, - timeout, - maxRetries, - apiKey, - ) + + fun build(): ClientOptions { + val httpClient = checkRequired( + "httpClient", httpClient + ) + + val headers = Headers.builder() + val queryParams = QueryParams.builder() + headers.put("X-Stainless-Lang", "java") + headers.put("X-Stainless-Arch", getOsArch()) + headers.put("X-Stainless-OS", getOsName()) + headers.put("X-Stainless-OS-Version", getOsVersion()) + headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime", "JRE") + headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + apiKey?.let { + if (!it.isEmpty()) { + headers.put("Authorization", "Bearer $it") + } + } + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) + + return ClientOptions( + httpClient, + PhantomReachableClosingHttpClient(RetryingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .maxRetries(maxRetries) + .build()), + jsonMapper, + clock, + baseUrl, + headers.build(), + queryParams.build(), + responseValidation, + timeout, + maxRetries, + apiKey, + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt index 588027c6..048e0759 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt @@ -2,8 +2,6 @@ package com.braintrustdata.api.core -import com.braintrustdata.api.errors.BraintrustException -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.databind.DeserializationFeature @@ -18,6 +16,8 @@ import com.fasterxml.jackson.databind.module.SimpleModule import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder +import com.braintrustdata.api.errors.BraintrustException +import com.braintrustdata.api.errors.BraintrustInvalidDataException import java.io.InputStream fun jsonMapper(): JsonMapper = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt index f98bf142..9c89c69c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt @@ -8,9 +8,6 @@ interface Params { /** The full set of headers in the parameters, including both fixed and additional headers. */ fun _headers(): Headers - /** - * The full set of query params in the parameters, including both fixed and additional query - * params. - */ + /** The full set of query params in the parameters, including both fixed and additional query params. */ fun _queryParams(): QueryParams } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt index e9aaadff..74b30572 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt @@ -6,7 +6,10 @@ import com.braintrustdata.api.core.http.HttpRequest import java.util.concurrent.CompletableFuture @JvmSynthetic -internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = +internal fun HttpRequest.prepare( + clientOptions: ClientOptions, + params: Params +): HttpRequest = toBuilder() .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params._queryParams()) @@ -17,8 +20,7 @@ internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): @JvmSynthetic internal fun HttpRequest.prepareAsync( clientOptions: ClientOptions, - params: Params, + params: Params ): CompletableFuture = - // This async version exists to make it easier to add async specific preparation logic in the - // future. + // This async version exists to make it easier to add async specific preparation logic in the future. CompletableFuture.completedFuture(prepare(clientOptions, params)) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt index a0924603..4c80349e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt @@ -9,12 +9,9 @@ fun getOsArch(): String { return when (osArch) { null -> "unknown" - "i386", - "x32", - "x86" -> "x32" - "amd64", - "x86_64" -> "x64" - "arm" -> "arm" + "i386", "x32", "x86" -> "x32" + "amd64", "x86_64" -> "x64" + "arm"-> "arm" "aarch64" -> "arm64" else -> "other:${osArch}" } @@ -36,7 +33,6 @@ fun getOsName(): String { fun getOsVersion(): String = System.getProperty("os.version", "unknown") -fun getPackageVersion(): String = - Properties::class.java.`package`.implementationVersion ?: "unknown" +fun getPackageVersion(): String = Properties::class.java.`package`.implementationVersion ?: "unknown" fun getJavaVersion(): String = System.getProperty("java.version", "unknown") diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt index fe7c8372..d68148e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt @@ -2,7 +2,11 @@ package com.braintrustdata.api.core import java.time.Duration -class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { +class RequestOptions +private constructor( + val responseValidation: Boolean?, + val timeout: Timeout?, +) { companion object { @@ -37,7 +41,9 @@ class RequestOptions private constructor(val responseValidation: Boolean?, val t this.responseValidation = responseValidation } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + this.timeout = timeout + } fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt index 6a0cdcc7..d07f5d3c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt @@ -8,12 +8,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** A class containing timeouts for various processing phases of a request. */ -class Timeout -private constructor( +class Timeout private constructor( private val connect: Duration?, private val read: Duration?, private val write: Duration?, private val request: Duration?, + ) { /** @@ -26,7 +26,8 @@ private constructor( fun connect(): Duration = connect ?: Duration.ofMinutes(1) /** - * The maximum time allowed between two data packets when waiting for the server’s response. + * The maximum time allowed between two data packets when waiting for the server’s + * response. * * A value of [Duration.ZERO] means there's no timeout. * @@ -35,7 +36,8 @@ private constructor( fun read(): Duration = read ?: request() /** - * The maximum time allowed between two data packets when sending the request to the server. + * The maximum time allowed between two data packets when sending the request to + * the server. * * A value of [Duration.ZERO] means there's no timeout. * @@ -46,8 +48,8 @@ private constructor( /** * The maximum time allowed for a complete HTTP call, not including retries. * - * This includes resolving DNS, connecting, writing the request body, server processing, as well - * as reading the response body. + * This includes resolving DNS, connecting, writing the request body, server + * processing, as well as reading the response body. * * A value of [Duration.ZERO] means there's no timeout. * @@ -59,10 +61,12 @@ private constructor( companion object { - @JvmStatic fun default() = builder().build() + @JvmStatic + fun default() = builder().build() /** Returns a mutable builder for constructing an instance of [Timeout]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Timeout]. */ @@ -74,12 +78,13 @@ private constructor( private var request: Duration? = null @JvmSynthetic - internal fun from(timeout: Timeout) = apply { - connect = timeout.connect - read = timeout.read - write = timeout.write - request = timeout.request - } + internal fun from(timeout: Timeout) = + apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } /** * The maximum time allowed to establish a connection with a host. @@ -88,7 +93,10 @@ private constructor( * * Defaults to `Duration.ofMinutes(1)`. */ - fun connect(connect: Duration?) = apply { this.connect = connect } + fun connect(connect: Duration?) = + apply { + this.connect = connect + } /** * The maximum time allowed to establish a connection with a host. @@ -100,16 +108,21 @@ private constructor( fun connect(connect: Optional) = connect(connect.getOrNull()) /** - * The maximum time allowed between two data packets when waiting for the server’s response. + * The maximum time allowed between two data packets when waiting for the server’s + * response. * * A value of [Duration.ZERO] means there's no timeout. * * Defaults to `request()`. */ - fun read(read: Duration?) = apply { this.read = read } + fun read(read: Duration?) = + apply { + this.read = read + } /** - * The maximum time allowed between two data packets when waiting for the server’s response. + * The maximum time allowed between two data packets when waiting for the server’s + * response. * * A value of [Duration.ZERO] means there's no timeout. * @@ -118,16 +131,21 @@ private constructor( fun read(read: Optional) = read(read.getOrNull()) /** - * The maximum time allowed between two data packets when sending the request to the server. + * The maximum time allowed between two data packets when sending the request to + * the server. * * A value of [Duration.ZERO] means there's no timeout. * * Defaults to `request()`. */ - fun write(write: Duration?) = apply { this.write = write } + fun write(write: Duration?) = + apply { + this.write = write + } /** - * The maximum time allowed between two data packets when sending the request to the server. + * The maximum time allowed between two data packets when sending the request to + * the server. * * A value of [Duration.ZERO] means there's no timeout. * @@ -138,20 +156,23 @@ private constructor( /** * The maximum time allowed for a complete HTTP call, not including retries. * - * This includes resolving DNS, connecting, writing the request body, server processing, as - * well as reading the response body. + * This includes resolving DNS, connecting, writing the request body, server + * processing, as well as reading the response body. * * A value of [Duration.ZERO] means there's no timeout. * * Defaults to `Duration.ofMinutes(1)`. */ - fun request(request: Duration?) = apply { this.request = request } + fun request(request: Duration?) = + apply { + this.request = request + } /** * The maximum time allowed for a complete HTTP call, not including retries. * - * This includes resolving DNS, connecting, writing the request body, server processing, as - * well as reading the response body. + * This includes resolving DNS, connecting, writing the request body, server + * processing, as well as reading the response body. * * A value of [Duration.ZERO] means there's no timeout. * @@ -159,7 +180,13 @@ private constructor( */ fun request(request: Optional) = request(request.getOrNull()) - fun build(): Timeout = Timeout(connect, read, write, request) + fun build(): Timeout = + Timeout( + connect, + read, + write, + request, + ) } @JvmSynthetic @@ -175,15 +202,14 @@ private constructor( .build() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ - override fun toString() = - "Timeout{connect=$connect, read=$read, write=$write, request=$request}" + override fun toString() = "Timeout{connect=$connect, read=$read, write=$write, request=$request}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index 6761ce6a..57ab7e19 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -18,7 +18,8 @@ internal fun List.toImmutable(): List = internal fun Map.toImmutable(): Map = if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) -@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() +@JvmSynthetic +internal fun immutableEmptyMap(): Map = Collections.emptyMap() @JvmSynthetic internal fun , V> SortedMap.toImmutable(): SortedMap = @@ -28,26 +29,26 @@ internal fun , V> SortedMap.toImmutable(): SortedMap { } /** - * If the "known" value (i.e. matching the type that the SDK expects) is returned by the API - * then this method will return an empty `Optional`, otherwise the returned `Optional` is given - * a `JsonValue`. + * If the "known" value (i.e. matching the type that the SDK expects) is returned + * by the API then this method will return an empty `Optional`, otherwise the + * returned `Optional` is given a `JsonValue`. */ fun asUnknown(): Optional = when (this) { @@ -88,8 +88,7 @@ sealed class JsonField { try { JsonValue.from(it) } catch (e: IllegalArgumentException) { - // The known value is a list, but not all values are convertible to - // `JsonValue`. + // The known value is a list, but not all values are convertible to `JsonValue`. return Optional.empty() } } @@ -112,8 +111,7 @@ sealed class JsonField { try { JsonValue.from(value) } catch (e: IllegalArgumentException) { - // The known value is a map, but not all items are convertible - // to `JsonValue`. + // The known value is a map, but not all items are convertible to `JsonValue`. return Optional.empty() } @@ -149,7 +147,8 @@ sealed class JsonField { is JsonValue -> this } - @JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + @JvmSynthetic + fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) fun accept(visitor: Visitor): R = when (this) { @@ -157,12 +156,13 @@ sealed class JsonField { is JsonValue -> accept(visitor as JsonValue.Visitor) } - interface Visitor : JsonValue.Visitor { + interface Visitor: JsonValue.Visitor { fun visitKnown(value: T): R = visitDefault() } companion object { - @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) + @JvmStatic + fun of(value: T): JsonField = KnownValue.of(value) @JvmStatic fun ofNullable(value: T?): JsonField = @@ -173,9 +173,8 @@ sealed class JsonField { } /** - * This class is a Jackson filter that can be used to exclude missing properties from objects. - * This filter should not be used directly and should instead use the @ExcludeMissing - * annotation. + * This class is a Jackson filter that can be used to exclude missing properties from objects. This filter + * should not be used directly and should instead use the @ExcludeMissing annotation. */ class IsMissing { override fun equals(other: Any?): Boolean = other is JsonMissing @@ -200,11 +199,11 @@ sealed class JsonField { } @JsonDeserialize(using = JsonValue.Deserializer::class) -sealed class JsonValue : JsonField() { +sealed class JsonValue: JsonField() { - fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) - fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) fun accept(visitor: Visitor): R = when (this) { @@ -219,19 +218,12 @@ sealed class JsonValue : JsonField() { interface Visitor { fun visitNull(): R = visitDefault() - fun visitMissing(): R = visitDefault() - fun visitBoolean(value: Boolean): R = visitDefault() - fun visitNumber(value: Number): R = visitDefault() - fun visitString(value: String): R = visitDefault() - fun visitArray(values: List): R = visitDefault() - fun visitObject(values: Map): R = visitDefault() - fun visitDefault(): R { throw RuntimeException("Unexpected value") } @@ -257,12 +249,8 @@ sealed class JsonValue : JsonField() { BOOLEAN -> JsonBoolean.of(node.booleanValue()) NUMBER -> JsonNumber.of(node.numberValue()) STRING -> JsonString.of(node.textValue()) - ARRAY -> - JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) - OBJECT -> - JsonObject.of( - node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap() - ) + ARRAY -> JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) + OBJECT -> JsonObject.of(node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap()) BINARY, POJO, null -> throw IllegalStateException("Unexpected JsonNode type: ${node.nodeType}") @@ -309,14 +297,11 @@ class JsonMissing : JsonValue() { @JvmStatic fun of() = INSTANCE } - class Serializer : BaseSerializer(JsonMissing::class) { - override fun serialize( - value: JsonMissing, - generator: JsonGenerator, - provider: SerializerProvider, - ) { + class Serializer: BaseSerializer(JsonMissing::class) { + override fun serialize(value: JsonMissing, generator: JsonGenerator, provider: SerializerProvider) { throw RuntimeException("JsonMissing cannot be serialized") } + } } @@ -417,7 +402,9 @@ private constructor( override fun toString() = values.toString() companion object { - @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) + @JsonCreator + @JvmStatic + fun of(values: List) = JsonArray(values.toImmutable()) } } @@ -448,7 +435,10 @@ private constructor( } @JacksonAnnotationsInside -@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) +@JsonInclude( + JsonInclude.Include.CUSTOM, + valueFilter = JsonField.IsMissing::class, +) annotation class ExcludeMissing @JacksonAnnotationsInside @@ -457,8 +447,7 @@ annotation class ExcludeMissing isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, creatorVisibility = Visibility.NONE, - fieldVisibility = Visibility.NONE, -) + fieldVisibility = Visibility.NONE) annotation class NoAutoDetect class MultipartField @@ -509,10 +498,7 @@ private constructor( return MultipartField( value, contentType - ?: if ( - value is KnownValue && - (value.value is InputStream || value.value is ByteArray) - ) + ?: if (value is KnownValue && (value.value is InputStream || value.value is ByteArray)) "application/octet-stream" else "text/plain; charset=utf-8", filename, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt index 12cfc384..28b08bfe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt @@ -2,19 +2,20 @@ package com.braintrustdata.api.core.handlers +import com.fasterxml.jackson.databind.json.JsonMapper import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BadRequestException -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.errors.InternalServerException import com.braintrustdata.api.errors.NotFoundException import com.braintrustdata.api.errors.PermissionDeniedException import com.braintrustdata.api.errors.RateLimitException +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.errors.BraintrustException import com.braintrustdata.api.errors.UnauthorizedException import com.braintrustdata.api.errors.UnexpectedStatusCodeException import com.braintrustdata.api.errors.UnprocessableEntityException -import com.fasterxml.jackson.databind.json.JsonMapper import java.io.ByteArrayInputStream import java.io.InputStream diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt index ae855a7b..041ed543 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt @@ -2,11 +2,12 @@ package com.braintrustdata.api.core.handlers +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.braintrustdata.api.core.enhanceJacksonException import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.braintrustdata.api.errors.BraintrustException @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt index 6d37e804..5530338e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt @@ -1,12 +1,13 @@ package com.braintrustdata.api.core.http import com.braintrustdata.api.core.toImmutable +import java.util.Collections import java.util.TreeMap class Headers private constructor( private val map: Map>, - @get:JvmName("size") val size: Int, + @get:JvmName("size") val size: Int ) { fun isEmpty(): Boolean = map.isEmpty() @@ -74,7 +75,7 @@ private constructor( values.toImmutable() } .toImmutable(), - size, + size ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt index 5941bacd..b797df53 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt @@ -1,8 +1,8 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.core.RequestOptions import java.lang.AutoCloseable import java.util.concurrent.CompletableFuture +import com.braintrustdata.api.core.RequestOptions interface HttpClient : AutoCloseable { @@ -11,7 +11,8 @@ interface HttpClient : AutoCloseable { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse - fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) + fun execute(request: HttpRequest): HttpResponse = + execute(request, RequestOptions.none()) fun executeAsync( request: HttpRequest, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index 1105f7d4..3ab2cb24 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -51,85 +51,129 @@ private constructor( this.pathSegments.addAll(pathSegments) } - fun headers(headers: Headers) = apply { - this.headers.clear() - putAllHeaders(headers) - } - - fun headers(headers: Map>) = apply { - this.headers.clear() - putAllHeaders(headers) - } - - fun putHeader(name: String, value: String) = apply { headers.put(name, value) } - - fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } - - fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } - - fun putAllHeaders(headers: Map>) = apply { - this.headers.putAll(headers) - } - - fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } - - fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replace(name, values) - } - - fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } - - fun replaceAllHeaders(headers: Map>) = apply { - this.headers.replaceAll(headers) - } - - fun removeHeaders(name: String) = apply { headers.remove(name) } - - fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } - - fun queryParams(queryParams: QueryParams) = apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } - - fun queryParams(queryParams: Map>) = apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } - - fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } - - fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.put(key, values) - } - - fun putAllQueryParams(queryParams: QueryParams) = apply { - this.queryParams.putAll(queryParams) - } - - fun putAllQueryParams(queryParams: Map>) = apply { - this.queryParams.putAll(queryParams) - } - - fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replace(key, value) - } - - fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replace(key, values) - } - - fun replaceAllQueryParams(queryParams: QueryParams) = apply { - this.queryParams.replaceAll(queryParams) - } - - fun replaceAllQueryParams(queryParams: Map>) = apply { - this.queryParams.replaceAll(queryParams) - } - - fun removeQueryParams(key: String) = apply { queryParams.remove(key) } - - fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + fun headers(headers: Headers) = + apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = + apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = + apply { + headers.put(name, value) + } + + fun putHeaders(name: String, values: Iterable) = + apply { + headers.put(name, values) + } + + fun putAllHeaders(headers: Headers) = + apply { + this.headers.putAll(headers) + } + + fun putAllHeaders(headers: Map>) = + apply { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = + apply { + headers.replace(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = + apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = + apply { + this.headers.replaceAll(headers) + } + + fun replaceAllHeaders(headers: Map>) = + apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = + apply { + headers.remove(name) + } + + fun removeAllHeaders(names: Set) = + apply { + headers.removeAll(names) + } + + fun queryParams(queryParams: QueryParams) = + apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = + apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = + apply { + queryParams.put(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = + apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = + apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = + apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = + apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = + apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = + apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = + apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = + apply { + queryParams.remove(key) + } + + fun removeAllQueryParams(keys: Set) = + apply { + queryParams.removeAll(keys) + } fun body(body: HttpRequestBody) = apply { this.body = body } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt index bb5b61ab..125e268b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt @@ -67,10 +67,7 @@ internal fun multipartFormData( .build() } - private fun serializePart( - name: String, - node: JsonNode, - ): Sequence> = + private fun serializePart(name: String, node: JsonNode): Sequence> = when (node.nodeType) { JsonNodeType.MISSING, JsonNodeType.NULL -> emptySequence() @@ -111,10 +108,7 @@ internal fun multipartFormData( serializePart("$name[$key]", value) } JsonNodeType.POJO, - null -> - throw BraintrustInvalidDataException( - "Unexpected JsonNode type: ${node.nodeType}" - ) + null -> throw BraintrustInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") } private fun String.toInputStream(): InputStream = ByteArrayInputStream(toByteArray()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt index ebf2b4d5..fae4bf81 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt @@ -12,11 +12,10 @@ interface HttpRequestBody : AutoCloseable { fun contentLength(): Long /** - * Determines if a request can be repeated in a meaningful way, for example before doing a - * retry. + * Determines if a request can be repeated in a meaningful way, for example before doing a retry. * - * The most typical case when a request can't be retried is if the request body is being - * streamed. In this case the body data isn't available on subsequent attempts. + * The most typical case when a request can't be retried is if the request body is being streamed. In this case the + * body data isn't available on subsequent attempts. */ fun repeatable(): Boolean diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt index e766e040..efd180a9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt @@ -19,7 +19,7 @@ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpCli override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions, + requestOptions: RequestOptions ): CompletableFuture = httpClient.executeAsync(request, requestOptions) override fun close() = httpClient.close() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt index 215eea16..2f2252b4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt @@ -5,7 +5,7 @@ import com.braintrustdata.api.core.toImmutable class QueryParams private constructor( private val map: Map>, - @get:JvmName("size") val size: Int, + @get:JvmName("size") val size: Int ) { fun isEmpty(): Boolean = map.isEmpty() @@ -69,7 +69,10 @@ private constructor( } fun build() = - QueryParams(map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), size) + QueryParams( + map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), + size + ) } override fun hashCode(): Int = map.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 56bdac87..61d75ca3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -1,8 +1,8 @@ package com.braintrustdata.api.core.http +import com.braintrustdata.api.errors.BraintrustIoException import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.checkRequired -import com.braintrustdata.api.errors.BraintrustIoException import java.io.IOException import java.time.Clock import java.time.Duration @@ -22,13 +22,16 @@ import kotlin.math.pow class RetryingHttpClient private constructor( - private val httpClient: HttpClient, - private val clock: Clock, - private val maxRetries: Int, - private val idempotencyHeader: String?, + private val httpClient: HttpClient, + private val clock: Clock, + private val maxRetries: Int, + private val idempotencyHeader: String?, ) : HttpClient { - override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.execute(request, requestOptions) } @@ -47,20 +50,20 @@ private constructor( } val response = - try { - val response = httpClient.execute(modifiedRequest, requestOptions) - if (++retries > maxRetries || !shouldRetry(response)) { - return response - } + try { + val response = httpClient.execute(modifiedRequest, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } - response - } catch (throwable: Throwable) { - if (++retries > maxRetries || !shouldRetry(throwable)) { - throw throwable - } + response + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable + } - null - } + null + } val backoffMillis = getRetryBackoffMillis(retries, response) // All responses must be closed, so close the failed one before retrying. @@ -70,8 +73,8 @@ private constructor( } override fun executeAsync( - request: HttpRequest, - requestOptions: RequestOptions, + request: HttpRequest, + requestOptions: RequestOptions, ): CompletableFuture { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.executeAsync(request, requestOptions) @@ -86,43 +89,42 @@ private constructor( var retries = 0 fun executeWithRetries( - request: HttpRequest, - requestOptions: RequestOptions, + request: HttpRequest, + requestOptions: RequestOptions, ): CompletableFuture { val requestWithRetryCount = if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request - return httpClient - .executeAsync(requestWithRetryCount, requestOptions) - .handleAsync( - fun( - response: HttpResponse?, - throwable: Throwable?, - ): CompletableFuture { - if (response != null) { - if (++retries > maxRetries || !shouldRetry(response)) { - return CompletableFuture.completedFuture(response) - } - } else { - if (++retries > maxRetries || !shouldRetry(throwable!!)) { - val failedFuture = CompletableFuture() - failedFuture.completeExceptionally(throwable) - return failedFuture - } - } - - val backoffMillis = getRetryBackoffMillis(retries, response) - // All responses must be closed, so close the failed one before retrying. - response?.close() - return sleepAsync(backoffMillis.toMillis()).thenCompose { - executeWithRetries(requestWithRetryCount, requestOptions) - } + return httpClient.executeAsync(requestWithRetryCount, requestOptions) + .handleAsync( + fun( + response: HttpResponse?, + throwable: Throwable? + ): CompletableFuture { + if (response != null) { + if (++retries > maxRetries || !shouldRetry(response)) { + return CompletableFuture.completedFuture(response) + } + } else { + if (++retries > maxRetries || !shouldRetry(throwable!!)) { + val failedFuture = CompletableFuture() + failedFuture.completeExceptionally(throwable) + return failedFuture + } + } + + val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + return sleepAsync(backoffMillis.toMillis()).thenCompose { + executeWithRetries(requestWithRetryCount, requestOptions) + } + }, + ) { + // Run in the same thread. + it.run() } - ) { - // Run in the same thread. - it.run() - } - .thenCompose(Function.identity()) + .thenCompose(Function.identity()) } return executeWithRetries(modifiedRequest, requestOptions) @@ -182,38 +184,30 @@ private constructor( private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After - response - ?.headers() - ?.let { headers -> - headers - .values("Retry-After-Ms") - .getOrNull(0) - ?.toFloatOrNull() - ?.times(TimeUnit.MILLISECONDS.toNanos(1)) + response?.headers()?.let { headers -> + headers.values("Retry-After-Ms").getOrNull(0)?.toFloatOrNull()?.times(TimeUnit.MILLISECONDS.toNanos(1)) ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) - ?: try { - ChronoUnit.MILLIS.between( - OffsetDateTime.now(clock), - OffsetDateTime.parse( - retryAfter, - DateTimeFormatter.RFC_1123_DATE_TIME, - ), - ) - } catch (e: DateTimeParseException) { - null - } + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME + ) + ) + } catch (e: DateTimeParseException) { + null + } } + }?.let { retryAfterNanos -> + // If the API asks us to wait a certain amount of time (and it's a reasonable amount), just + // do what it says. + val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) + if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { + return retryAfter } - ?.let { retryAfterNanos -> - // If the API asks us to wait a certain amount of time (and it's a reasonable - // amount), just - // do what it says. - val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) - if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { - return retryAfter - } - } + } // Apply exponential backoff, but not more than the max. val backoffSeconds = min(0.5 * 2.0.pow(retries - 1), 8.0) @@ -231,17 +225,18 @@ private constructor( private fun sleepAsync(millis: Long): CompletableFuture { val future = CompletableFuture() TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis, + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + millis ) return future } - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder internal constructor() { @@ -260,11 +255,11 @@ private constructor( fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } fun build(): HttpClient = - RetryingHttpClient( - checkRequired("httpClient", httpClient), - clock, - maxRetries, - idempotencyHeader, - ) + RetryingHttpClient( + checkRequired("httpClient", httpClient), + clock, + maxRetries, + idempotencyHeader, + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt index b8c65254..83ec706e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class BadRequestException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(400, headers, body, error) +class BadRequestException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(400, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index afcc62d2..d2e399b6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -13,14 +13,9 @@ import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects @NoAutoDetect -class BraintrustError -@JsonCreator -private constructor( - @JsonAnyGetter - @ExcludeMissing - @JsonAnySetter - @get:JvmName("additionalProperties") - val additionalProperties: Map = immutableEmptyMap() +class BraintrustError @JsonCreator private constructor( + @JsonAnyGetter @ExcludeMissing @JsonAnySetter @get:JvmName("additionalProperties") val additionalProperties: Map = immutableEmptyMap(), + ) { fun toBuilder() = Builder().from(this) @@ -28,7 +23,8 @@ private constructor( companion object { /** Returns a mutable builder for constructing an instance of [BraintrustError]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [BraintrustError]. */ @@ -37,38 +33,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(braintrustError: BraintrustError) = apply { - additionalProperties = braintrustError.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(braintrustError: BraintrustError) = + apply { + additionalProperties = braintrustError.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): BraintrustError = BraintrustError(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is BraintrustError && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BraintrustError && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt index d1fdfdee..78a326db 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt @@ -2,5 +2,4 @@ package com.braintrustdata.api.errors class BraintrustInvalidDataException @JvmOverloads -constructor(message: String? = null, cause: Throwable? = null) : - BraintrustException(message, cause) +constructor(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt index 6fb793a1..b7e0d934 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt @@ -2,5 +2,4 @@ package com.braintrustdata.api.errors class BraintrustIoException @JvmOverloads -constructor(message: String? = null, cause: Throwable? = null) : - BraintrustException(message, cause) +constructor(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt index 728ac6bd..fb883c12 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt @@ -5,12 +5,12 @@ import com.braintrustdata.api.core.http.Headers abstract class BraintrustServiceException @JvmOverloads constructor( - private val statusCode: Int, - private val headers: Headers, - private val body: String, - private val error: BraintrustError, - message: String = "$statusCode: $error", - cause: Throwable? = null, + private val statusCode: Int, + private val headers: Headers, + private val body: String, + private val error: BraintrustError, + message: String = "$statusCode: $error", + cause: Throwable? = null ) : BraintrustException(message, cause) { fun statusCode(): Int = statusCode diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt index 36cc4432..b2eadeb8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt @@ -3,8 +3,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers class InternalServerException( - statusCode: Int, - headers: Headers, - body: String, - error: BraintrustError, + statusCode: Int, + headers: Headers, + body: String, + error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt index ecc1a307..cd43aa64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class NotFoundException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(404, headers, body, error) +class NotFoundException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(404, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt index 27380e3e..72fb9d36 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class PermissionDeniedException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(403, headers, body, error) +class PermissionDeniedException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(403, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt index a9352a3a..be083e9c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class RateLimitException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(429, headers, body, error) +class RateLimitException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(429, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt index 57f9242f..d5541528 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class UnauthorizedException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(401, headers, body, error) +class UnauthorizedException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(401, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt index 7aa10d9b..c460ecad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt @@ -3,8 +3,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers class UnexpectedStatusCodeException( - statusCode: Int, - headers: Headers, - body: String, - error: BraintrustError, + statusCode: Int, + headers: Headers, + body: String, + error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt index 6e216b4e..b3d59795 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class UnprocessableEntityException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(422, headers, body, error) +class UnprocessableEntityException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(422, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index baafa57f..7da801b6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -20,23 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class AISecret -@JsonCreator -private constructor( +class AISecret @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("preview_secret") - @ExcludeMissing - private val previewSecret: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("preview_secret") @ExcludeMissing private val previewSecret: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the AI secret */ @@ -53,30 +46,41 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - fun previewSecret(): Optional = - Optional.ofNullable(previewSecret.getNullable("preview_secret")) + fun previewSecret(): Optional = Optional.ofNullable(previewSecret.getNullable("preview_secret")) fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Unique identifier for the AI secret */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Date of AI secret creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonProperty("preview_secret") @ExcludeMissing fun _previewSecret(): JsonField = previewSecret - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -84,20 +88,21 @@ private constructor( private var validated: Boolean = false - fun validate(): AISecret = apply { - if (validated) { - return@apply - } + fun validate(): AISecret = + apply { + if (validated) { + return@apply + } - id() - name() - orgId() - created() - metadata().ifPresent { it.validate() } - previewSecret() - type() - validated = true - } + id() + name() + orgId() + created() + metadata().ifPresent { it.validate() } + previewSecret() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -107,13 +112,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [AISecret]. * * The following fields are required: + * * ```java * .id() * .name() * .orgId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AISecret]. */ @@ -129,34 +136,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecret: AISecret) = apply { - id = aiSecret.id - name = aiSecret.name - orgId = aiSecret.orgId - created = aiSecret.created - metadata = aiSecret.metadata - previewSecret = aiSecret.previewSecret - type = aiSecret.type - additionalProperties = aiSecret.additionalProperties.toMutableMap() - } + internal fun from(aiSecret: AISecret) = + apply { + id = aiSecret.id + name = aiSecret.name + orgId = aiSecret.orgId + created = aiSecret.created + metadata = aiSecret.metadata + previewSecret = aiSecret.previewSecret + type = aiSecret.type + additionalProperties = aiSecret.additionalProperties.toMutableMap() + } /** Unique identifier for the AI secret */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the AI secret */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Date of AI secret creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -165,68 +182,87 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of AI secret creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } - fun previewSecret(previewSecret: String?) = - previewSecret(JsonField.ofNullable(previewSecret)) + fun previewSecret(previewSecret: String?) = previewSecret(JsonField.ofNullable(previewSecret)) - fun previewSecret(previewSecret: Optional) = - previewSecret(previewSecret.getOrNull()) + fun previewSecret(previewSecret: Optional) = previewSecret(previewSecret.getOrNull()) - fun previewSecret(previewSecret: JsonField) = apply { - this.previewSecret = previewSecret - } + fun previewSecret(previewSecret: JsonField) = + apply { + this.previewSecret = previewSecret + } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AISecret = AISecret( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("orgId", orgId), - created, - metadata, - previewSecret, - type, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + created, + metadata, + previewSecret, + type, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -235,20 +271,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -257,38 +295,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -301,11 +347,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -314,6 +360,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt index f408b1d3..0eb35bf2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt @@ -22,48 +22,31 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read permissions on - * a project, they will also have read permissions on any experiment, dataset, etc. created within - * that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect -class Acl -@JsonCreator -private constructor( +class Acl @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_object_org_id") - @ExcludeMissing - private val _objectOrgId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("_object_org_id") @ExcludeMissing private val _objectOrgId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the acl */ @@ -82,31 +65,39 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the acl */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** The organization the ACL's referred object belongs to */ @JsonProperty("_object_org_id") @@ -114,7 +105,9 @@ private constructor( fun __objectOrgId(): JsonField = _objectOrgId /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -122,33 +115,49 @@ private constructor( fun _objectType(): JsonField = objectType /** Date of acl creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -156,23 +165,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Acl = apply { - if (validated) { - return@apply - } + fun validate(): Acl = + apply { + if (validated) { + return@apply + } - id() - _objectOrgId() - objectId() - objectType() - created() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } + id() + _objectOrgId() + objectId() + objectType() + created() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -182,6 +192,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Acl]. * * The following fields are required: + * * ```java * .id() * ._objectOrgId() @@ -189,7 +200,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Acl]. */ @@ -208,45 +220,56 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(acl: Acl) = apply { - id = acl.id - _objectOrgId = acl._objectOrgId - objectId = acl.objectId - objectType = acl.objectType - created = acl.created - groupId = acl.groupId - permission = acl.permission - restrictObjectType = acl.restrictObjectType - roleId = acl.roleId - userId = acl.userId - additionalProperties = acl.additionalProperties.toMutableMap() - } + internal fun from(acl: Acl) = + apply { + id = acl.id + _objectOrgId = acl._objectOrgId + objectId = acl.objectId + objectType = acl.objectType + created = acl.created + groupId = acl.groupId + permission = acl.permission + restrictObjectType = acl.restrictObjectType + roleId = acl.roleId + userId = acl.userId + additionalProperties = acl.additionalProperties.toMutableMap() + } /** Unique identifier for the acl */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the acl */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** The organization the ACL's referred object belongs to */ fun _objectOrgId(_objectOrgId: String) = _objectOrgId(JsonField.of(_objectOrgId)) /** The organization the ACL's referred object belongs to */ - fun _objectOrgId(_objectOrgId: JsonField) = apply { - this._objectOrgId = _objectOrgId - } + fun _objectOrgId(_objectOrgId: JsonField) = + apply { + this._objectOrgId = _objectOrgId + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** Date of acl creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -255,137 +278,182 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of acl creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = apply { this.permission = permission } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Acl = Acl( - checkRequired("id", id), - checkRequired("_objectOrgId", _objectOrgId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - created, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_objectOrgId", _objectOrgId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + created, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -433,9 +501,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -451,17 +521,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -482,11 +553,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -507,23 +578,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -531,18 +599,25 @@ private constructor( override fun toString() = value.toString() } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @JsonCreator private constructor(private val value: JsonField) : Enum { + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -581,9 +656,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -596,17 +673,18 @@ private constructor( UPDATE_ACLS, DELETE_ACLS, /** - * An enum member indicating that [Permission] was instantiated with an unknown value. + * An enum member indicating that [Permission] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -624,11 +702,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -646,23 +724,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -671,22 +746,24 @@ private constructor( } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -731,12 +808,16 @@ private constructor( } /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RestrictObjectType] can contain an unknown value in a couple of + * cases: + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. * - * An instance of [RestrictObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -752,18 +833,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [RestrictObjectType] was instantiated with an unknown - * value. + * An enum member indicating that [RestrictObjectType] was instantiated with an + * unknown value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -784,11 +865,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -809,23 +890,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -834,11 +912,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Acl && id == other.id && _objectOrgId == other._objectOrgId && objectId == other.objectId && objectType == other.objectType && created == other.created && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Acl && id == other.id && _objectOrgId == other._objectOrgId && objectId == other.objectId && objectType == other.objectType && created == other.created && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -847,6 +925,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Acl{id=$id, _objectOrgId=$_objectOrgId, objectId=$objectId, objectType=$objectType, created=$created, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Acl{id=$id, _objectOrgId=$_objectOrgId, objectId=$objectId, objectType=$objectType, created=$created, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt index c7232bb9..bf9e92e9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt @@ -25,61 +25,70 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have no - * effect, and removing acls which do not exist will have no effect. + * Batch update acls. This operation is idempotent, so adding acls which already + * exist will have no effect, and removing acls which do not exist will have no + * effect. */ -class AclBatchUpdateParams -private constructor( +class AclBatchUpdateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(): Optional> = body.addAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun removeAcls(): Optional> = body.removeAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun _addAcls(): JsonField> = body._addAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun _removeAcls(): JsonField> = body._removeAcls() @@ -89,72 +98,76 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("add_acls") - @ExcludeMissing - private val addAcls: JsonField> = JsonMissing.of(), - @JsonProperty("remove_acls") - @ExcludeMissing - private val removeAcls: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("add_acls") @ExcludeMissing private val addAcls: JsonField> = JsonMissing.of(), + @JsonProperty("remove_acls") @ExcludeMissing private val removeAcls: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(): Optional> = Optional.ofNullable(addAcls.getNullable("add_acls")) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(): Optional> = - Optional.ofNullable(removeAcls.getNullable("remove_acls")) + fun removeAcls(): Optional> = Optional.ofNullable(removeAcls.getNullable("remove_acls")) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - @JsonProperty("add_acls") @ExcludeMissing fun _addAcls(): JsonField> = addAcls + @JsonProperty("add_acls") + @ExcludeMissing + fun _addAcls(): JsonField> = addAcls /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @JsonProperty("remove_acls") @ExcludeMissing @@ -166,22 +179,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - addAcls().ifPresent { it.forEach { it.validate() } } - removeAcls().ifPresent { it.forEach { it.validate() } } - validated = true - } + addAcls().ifPresent { it.forEach { it.validate() } } + removeAcls().ifPresent { it.forEach { it.validate() } } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -192,165 +207,181 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - addAcls = body.addAcls.map { it.toMutableList() } - removeAcls = body.removeAcls.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + addAcls = body.addAcls.map { it.toMutableList() } + removeAcls = body.removeAcls.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(addAcls: List?) = addAcls(JsonField.ofNullable(addAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAcls(addAcls: JsonField>) = apply { - this.addAcls = addAcls.map { it.toMutableList() } - } + fun addAcls(addAcls: JsonField>) = + apply { + this.addAcls = addAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAddAcl(addAcl: AddAcl) = apply { - addAcls = - (addAcls ?: JsonField.of(mutableListOf())).also { + fun addAddAcl(addAcl: AddAcl) = + apply { + addAcls = (addAcls ?: JsonField.of(mutableListOf())).also { checkKnown("addAcls", it).add(addAcl) } - } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: List?) = - removeAcls(JsonField.ofNullable(removeAcls)) + fun removeAcls(removeAcls: List?) = removeAcls(JsonField.ofNullable(removeAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: Optional>) = - removeAcls(removeAcls.getOrNull()) + fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: JsonField>) = apply { - this.removeAcls = removeAcls.map { it.toMutableList() } - } + fun removeAcls(removeAcls: JsonField>) = + apply { + this.removeAcls = removeAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addRemoveAcl(removeAcl: RemoveAcl) = apply { - removeAcls = - (removeAcls ?: JsonField.of(mutableListOf())).also { + fun addRemoveAcl(removeAcl: RemoveAcl) = + apply { + removeAcls = (removeAcls ?: JsonField.of(mutableListOf())).also { checkKnown("removeAcls", it).add(removeAcl) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, - (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, + (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -359,18 +390,22 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" + override fun toString() = "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): AclBatchUpdateParams = builder().build() + @JvmStatic + fun none(): AclBatchUpdateParams = builder().build() - /** Returns a mutable builder for constructing an instance of [AclBatchUpdateParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [AclBatchUpdateParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [AclBatchUpdateParams]. */ @@ -382,272 +417,325 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = apply { - body = aclBatchUpdateParams.body.toBuilder() - additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = + apply { + body = aclBatchUpdateParams.body.toBuilder() + additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAcls(addAcls: List?) = apply { body.addAcls(addAcls) } + fun addAcls(addAcls: List?) = + apply { + body.addAcls(addAcls) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAcls(addAcls: JsonField>) = apply { body.addAcls(addAcls) } + fun addAcls(addAcls: JsonField>) = + apply { + body.addAcls(addAcls) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAddAcl(addAcl: AddAcl) = apply { body.addAddAcl(addAcl) } + fun addAddAcl(addAcl: AddAcl) = + apply { + body.addAddAcl(addAcl) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: List?) = apply { body.removeAcls(removeAcls) } + fun removeAcls(removeAcls: List?) = + apply { + body.removeAcls(removeAcls) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: JsonField>) = apply { - body.removeAcls(removeAcls) - } + fun removeAcls(removeAcls: JsonField>) = + apply { + body.removeAcls(removeAcls) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addRemoveAcl(removeAcl: RemoveAcl) = apply { body.addRemoveAcl(removeAcl) } + fun addRemoveAcl(removeAcl: RemoveAcl) = + apply { + body.addRemoveAcl(removeAcl) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclBatchUpdateParams = AclBatchUpdateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect - class AddAcl - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class AddAcl @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the ACL applies to */ @@ -657,35 +745,39 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -693,34 +785,44 @@ private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -728,20 +830,21 @@ private constructor( private var validated: Boolean = false - fun validate(): AddAcl = apply { - if (validated) { - return@apply - } + fun validate(): AddAcl = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -751,12 +854,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [AddAcl]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AddAcl]. */ @@ -772,87 +877,98 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addAcl: AddAcl) = apply { - objectId = addAcl.objectId - objectType = addAcl.objectType - groupId = addAcl.groupId - permission = addAcl.permission - restrictObjectType = addAcl.restrictObjectType - roleId = addAcl.roleId - userId = addAcl.userId - additionalProperties = addAcl.additionalProperties.toMutableMap() - } + internal fun from(addAcl: AddAcl) = + apply { + objectId = addAcl.objectId + objectType = addAcl.objectType + groupId = addAcl.groupId + permission = addAcl.permission + restrictObjectType = addAcl.restrictObjectType + roleId = addAcl.roleId + userId = addAcl.userId + additionalProperties = addAcl.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -870,71 +986,91 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AddAcl = AddAcl( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -982,9 +1118,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1010,8 +1148,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1036,7 +1174,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1060,20 +1198,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1081,19 +1216,25 @@ private constructor( override fun toString() = value.toString() } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1132,9 +1273,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1157,8 +1300,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1180,7 +1323,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1201,20 +1344,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1223,22 +1363,24 @@ private constructor( } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1288,9 +1430,11 @@ private constructor( * * An instance of [RestrictObjectType] can contain an unknown value in a couple of * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1316,8 +1460,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1342,7 +1486,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1357,8 +1501,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1367,20 +1510,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1389,11 +1529,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1402,47 +1542,32 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect - class RemoveAcl - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RemoveAcl @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the ACL applies to */ @@ -1452,35 +1577,39 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -1488,34 +1617,44 @@ private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -1523,20 +1662,21 @@ private constructor( private var validated: Boolean = false - fun validate(): RemoveAcl = apply { - if (validated) { - return@apply - } + fun validate(): RemoveAcl = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1546,12 +1686,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [RemoveAcl]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RemoveAcl]. */ @@ -1567,87 +1709,98 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeAcl: RemoveAcl) = apply { - objectId = removeAcl.objectId - objectType = removeAcl.objectType - groupId = removeAcl.groupId - permission = removeAcl.permission - restrictObjectType = removeAcl.restrictObjectType - roleId = removeAcl.roleId - userId = removeAcl.userId - additionalProperties = removeAcl.additionalProperties.toMutableMap() - } + internal fun from(removeAcl: RemoveAcl) = + apply { + objectId = removeAcl.objectId + objectType = removeAcl.objectType + groupId = removeAcl.groupId + permission = removeAcl.permission + restrictObjectType = removeAcl.restrictObjectType + roleId = removeAcl.roleId + userId = removeAcl.userId + additionalProperties = removeAcl.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -1665,71 +1818,91 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RemoveAcl = RemoveAcl( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1777,9 +1950,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1805,8 +1980,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1831,7 +2006,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1855,20 +2030,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1876,19 +2048,25 @@ private constructor( override fun toString() = value.toString() } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1927,9 +2105,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1952,8 +2132,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1975,7 +2155,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1996,20 +2176,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2018,22 +2195,24 @@ private constructor( } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2083,9 +2262,11 @@ private constructor( * * An instance of [RestrictObjectType] can contain an unknown value in a couple of * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2111,8 +2292,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2137,7 +2318,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2152,8 +2333,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -2162,20 +2342,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2184,11 +2361,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2197,20 +2374,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index eec25147..6c708b70 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -18,63 +18,68 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class AclBatchUpdateResponse -@JsonCreator -private constructor( - @JsonProperty("added_acls") - @ExcludeMissing - private val addedAcls: JsonField> = JsonMissing.of(), - @JsonProperty("removed_acls") - @ExcludeMissing - private val removedAcls: JsonField> = JsonMissing.of(), +class AclBatchUpdateResponse @JsonCreator private constructor( + @JsonProperty("added_acls") @ExcludeMissing private val addedAcls: JsonField> = JsonMissing.of(), + @JsonProperty("removed_acls") @ExcludeMissing private val removedAcls: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addedAcls(): List = addedAcls.getRequired("added_acls") /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun removedAcls(): List = removedAcls.getRequired("removed_acls") /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - @JsonProperty("added_acls") @ExcludeMissing fun _addedAcls(): JsonField> = addedAcls + @JsonProperty("added_acls") + @ExcludeMissing + fun _addedAcls(): JsonField> = addedAcls /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @JsonProperty("removed_acls") @ExcludeMissing @@ -86,30 +91,34 @@ private constructor( private var validated: Boolean = false - fun validate(): AclBatchUpdateResponse = apply { - if (validated) { - return@apply - } + fun validate(): AclBatchUpdateResponse = + apply { + if (validated) { + return@apply + } - addedAcls().forEach { it.validate() } - removedAcls().forEach { it.validate() } - validated = true - } + addedAcls().forEach { it.validate() } + removedAcls().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [AclBatchUpdateResponse]. + * Returns a mutable builder for constructing an instance of + * [AclBatchUpdateResponse]. * * The following fields are required: + * * ```java * .addedAcls() * .removedAcls() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclBatchUpdateResponse]. */ @@ -120,131 +129,157 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aclBatchUpdateResponse: AclBatchUpdateResponse) = apply { - addedAcls = aclBatchUpdateResponse.addedAcls.map { it.toMutableList() } - removedAcls = aclBatchUpdateResponse.removedAcls.map { it.toMutableList() } - additionalProperties = aclBatchUpdateResponse.additionalProperties.toMutableMap() - } + internal fun from(aclBatchUpdateResponse: AclBatchUpdateResponse) = + apply { + addedAcls = aclBatchUpdateResponse.addedAcls.map { it.toMutableList() } + removedAcls = aclBatchUpdateResponse.removedAcls.map { it.toMutableList() } + additionalProperties = aclBatchUpdateResponse.additionalProperties.toMutableMap() + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addedAcls(addedAcls: List) = addedAcls(JsonField.of(addedAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addedAcls(addedAcls: JsonField>) = apply { - this.addedAcls = addedAcls.map { it.toMutableList() } - } + fun addedAcls(addedAcls: JsonField>) = + apply { + this.addedAcls = addedAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAddedAcl(addedAcl: Acl) = apply { - addedAcls = - (addedAcls ?: JsonField.of(mutableListOf())).also { + fun addAddedAcl(addedAcl: Acl) = + apply { + addedAcls = (addedAcls ?: JsonField.of(mutableListOf())).also { checkKnown("addedAcls", it).add(addedAcl) } - } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun removedAcls(removedAcls: List) = removedAcls(JsonField.of(removedAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removedAcls(removedAcls: JsonField>) = apply { - this.removedAcls = removedAcls.map { it.toMutableList() } - } + fun removedAcls(removedAcls: JsonField>) = + apply { + this.removedAcls = removedAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addRemovedAcl(removedAcl: Acl) = apply { - removedAcls = - (removedAcls ?: JsonField.of(mutableListOf())).also { + fun addRemovedAcl(removedAcl: Acl) = + apply { + removedAcls = (removedAcls ?: JsonField.of(mutableListOf())).also { checkKnown("removedAcls", it).add(removedAcl) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AclBatchUpdateResponse = AclBatchUpdateResponse( - checkRequired("addedAcls", addedAcls).map { it.toImmutable() }, - checkRequired("removedAcls", removedAcls).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "addedAcls", addedAcls + ).map { it.toImmutable() }, + checkRequired( + "removedAcls", removedAcls + ).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclBatchUpdateResponse && addedAcls == other.addedAcls && removedAcls == other.removedAcls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateResponse && addedAcls == other.addedAcls && removedAcls == other.removedAcls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -253,6 +288,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AclBatchUpdateResponse{addedAcls=$addedAcls, removedAcls=$removedAcls, additionalProperties=$additionalProperties}" + override fun toString() = "AclBatchUpdateResponse{addedAcls=$addedAcls, removedAcls=$removedAcls, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt index 58566fc6..5cb6f558 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt @@ -24,14 +24,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in the - * request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one + * specified in the request, will return the existing acl unmodified */ -class AclCreateParams -private constructor( +class AclCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The id of the object the ACL applies to */ @@ -41,24 +41,32 @@ private constructor( fun objectType(): ObjectType = body.objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = body.groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(): Optional = body.permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(): Optional = body.restrictObjectType() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun roleId(): Optional = body.roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = body.userId() @@ -69,24 +77,32 @@ private constructor( fun _objectType(): JsonField = body._objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun _groupId(): JsonField = body._groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun _permission(): JsonField = body._permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ fun _restrictObjectType(): JsonField = body._restrictObjectType() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun _roleId(): JsonField = body._roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun _userId(): JsonField = body._userId() @@ -96,49 +112,36 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the ACL applies to */ @@ -148,35 +151,39 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -184,34 +191,44 @@ private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -219,21 +236,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true } - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -242,12 +260,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -263,87 +283,98 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - objectId = body.objectId - objectType = body.objectType - groupId = body.groupId - permission = body.permission - restrictObjectType = body.restrictObjectType - roleId = body.roleId - userId = body.userId - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + objectId = body.objectId + objectType = body.objectType + groupId = body.groupId + permission = body.permission + restrictObjectType = body.restrictObjectType + roleId = body.roleId + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -361,64 +392,81 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -427,8 +475,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -439,12 +486,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [AclCreateParams]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclCreateParams]. */ @@ -456,240 +505,332 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclCreateParams: AclCreateParams) = apply { - body = aclCreateParams.body.toBuilder() - additionalHeaders = aclCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = aclCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(aclCreateParams: AclCreateParams) = + apply { + body = aclCreateParams.body.toBuilder() + additionalHeaders = aclCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = aclCreateParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: String?) = apply { body.groupId(groupId) } + fun groupId(groupId: String?) = + apply { + body.groupId(groupId) + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } + fun groupId(groupId: JsonField) = + apply { + body.groupId(groupId) + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission?) = apply { body.permission(permission) } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: Permission?) = + apply { + body.permission(permission) + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = apply { body.permission(permission) } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: JsonField) = + apply { + body.permission(permission) + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = apply { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + apply { + body.restrictObjectType(restrictObjectType) + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + body.restrictObjectType(restrictObjectType) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: String?) = apply { body.roleId(roleId) } + fun roleId(roleId: String?) = + apply { + body.roleId(roleId) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } + fun roleId(roleId: JsonField) = + apply { + body.roleId(roleId) + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclCreateParams = - AclCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + AclCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -737,9 +878,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -755,17 +898,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -786,11 +930,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -811,23 +955,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -835,18 +976,25 @@ private constructor( override fun toString() = value.toString() } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @JsonCreator private constructor(private val value: JsonField) : Enum { + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -885,9 +1033,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -900,17 +1050,18 @@ private constructor( UPDATE_ACLS, DELETE_ACLS, /** - * An enum member indicating that [Permission] was instantiated with an unknown value. + * An enum member indicating that [Permission] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -928,11 +1079,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -950,23 +1101,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -975,22 +1123,24 @@ private constructor( } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1035,12 +1185,16 @@ private constructor( } /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RestrictObjectType] can contain an unknown value in a couple of + * cases: + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. * - * An instance of [RestrictObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1056,18 +1210,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [RestrictObjectType] was instantiated with an unknown - * value. + * An enum member indicating that [RestrictObjectType] was instantiated with an + * unknown value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1088,11 +1242,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1113,23 +1267,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1138,15 +1289,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index 53bbe12f..91337103 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an acl object by its id */ -class AclDeleteParams -private constructor( +class AclDeleteParams private constructor( private val aclId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Acl id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [AclDeleteParams]. * * The following fields are required: + * * ```java * .aclId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aclDeleteParams: AclDeleteParams) = apply { - aclId = aclDeleteParams.aclId - additionalHeaders = aclDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aclDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aclDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(aclDeleteParams: AclDeleteParams) = + apply { + aclId = aclDeleteParams.aclId + additionalHeaders = aclDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aclDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aclDeleteParams.additionalBodyProperties.toMutableMap() + } /** Acl id */ - fun aclId(aclId: String) = apply { this.aclId = aclId } + fun aclId(aclId: String) = + apply { + this.aclId = aclId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): AclDeleteParams = AclDeleteParams( - checkRequired("aclId", aclId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "aclId", aclId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclDeleteParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclDeleteParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParams.kt index 43a401e5..7281b052 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParams.kt @@ -24,11 +24,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Delete a single acl */ -class AclFindAndDeleteParams -private constructor( +class AclFindAndDeleteParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The id of the object the ACL applies to */ @@ -38,24 +38,32 @@ private constructor( fun objectType(): ObjectType = body.objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = body.groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(): Optional = body.permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(): Optional = body.restrictObjectType() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun roleId(): Optional = body.roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = body.userId() @@ -66,24 +74,32 @@ private constructor( fun _objectType(): JsonField = body._objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun _groupId(): JsonField = body._groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun _permission(): JsonField = body._permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ fun _restrictObjectType(): JsonField = body._restrictObjectType() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun _roleId(): JsonField = body._roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun _userId(): JsonField = body._userId() @@ -93,49 +109,36 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the ACL applies to */ @@ -145,35 +148,39 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -181,34 +188,44 @@ private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -216,21 +233,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true } - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -239,12 +257,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -260,87 +280,98 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - objectId = body.objectId - objectType = body.objectType - groupId = body.groupId - permission = body.permission - restrictObjectType = body.restrictObjectType - roleId = body.roleId - userId = body.userId - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + objectId = body.objectId + objectType = body.objectType + groupId = body.groupId + permission = body.permission + restrictObjectType = body.restrictObjectType + roleId = body.roleId + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -358,64 +389,81 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -424,8 +472,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -433,15 +480,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AclFindAndDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [AclFindAndDeleteParams]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclFindAndDeleteParams]. */ @@ -453,244 +503,332 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclFindAndDeleteParams: AclFindAndDeleteParams) = apply { - body = aclFindAndDeleteParams.body.toBuilder() - additionalHeaders = aclFindAndDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aclFindAndDeleteParams.additionalQueryParams.toBuilder() - } + internal fun from(aclFindAndDeleteParams: AclFindAndDeleteParams) = + apply { + body = aclFindAndDeleteParams.body.toBuilder() + additionalHeaders = aclFindAndDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aclFindAndDeleteParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: String?) = apply { body.groupId(groupId) } + fun groupId(groupId: String?) = + apply { + body.groupId(groupId) + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } + fun groupId(groupId: JsonField) = + apply { + body.groupId(groupId) + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission?) = apply { body.permission(permission) } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: Permission?) = + apply { + body.permission(permission) + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = apply { body.permission(permission) } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: JsonField) = + apply { + body.permission(permission) + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = apply { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + apply { + body.restrictObjectType(restrictObjectType) + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + body.restrictObjectType(restrictObjectType) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: String?) = apply { body.roleId(roleId) } + fun roleId(roleId: String?) = + apply { + body.roleId(roleId) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } + fun roleId(roleId: JsonField) = + apply { + body.roleId(roleId) + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclFindAndDeleteParams = AclFindAndDeleteParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -738,9 +876,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -756,17 +896,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -787,11 +928,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -812,23 +953,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -836,18 +974,25 @@ private constructor( override fun toString() = value.toString() } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @JsonCreator private constructor(private val value: JsonField) : Enum { + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -886,9 +1031,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -901,17 +1048,18 @@ private constructor( UPDATE_ACLS, DELETE_ACLS, /** - * An enum member indicating that [Permission] was instantiated with an unknown value. + * An enum member indicating that [Permission] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -929,11 +1077,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -951,23 +1099,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -976,22 +1121,24 @@ private constructor( } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1036,12 +1183,16 @@ private constructor( } /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RestrictObjectType] can contain an unknown value in a couple of + * cases: + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. * - * An instance of [RestrictObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1057,18 +1208,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [RestrictObjectType] was instantiated with an unknown - * value. + * An enum member indicating that [RestrictObjectType] was instantiated with an + * unknown value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1089,11 +1240,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1114,23 +1265,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1139,15 +1287,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index f265a4be..e4cc0a07 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.AclService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ -class AclListPage -private constructor( +class AclListPage private constructor( private val aclsService: AclService, private val params: AclListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclListPage && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AclListPage && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ - override fun toString() = - "AclListPage{aclsService=$aclsService, params=$params, response=$response}" + override fun toString() = "AclListPage{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - AclListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - AclListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(AclListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(AclListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { aclsService.list(it) } + return getNextPageParams().map { aclsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(aclsService: AclService, params: AclListParams, response: Response) = - AclListPage(aclsService, params, response) + AclListPage( + aclsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [AclListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: AclListPage) : Iterable { + class AutoPager( + private val firstPage: AclListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index 9d691383..e5906d51 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.AclServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ -class AclListPageAsync -private constructor( +class AclListPageAsync private constructor( private val aclsService: AclServiceAsync, private val params: AclListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclListPageAsync && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AclListPageAsync && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ - override fun toString() = - "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" + override fun toString() = "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - AclListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - AclListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(AclListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(AclListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { aclsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + aclsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(aclsService: AclServiceAsync, params: AclListParams, response: Response) = - AclListPageAsync(aclsService, params, response) + AclListPageAsync( + aclsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [AclListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: AclListPageAsync) { + class AutoPager( + private val firstPage: AclListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Acl) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Acl) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt index 46304214..2a622bec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt @@ -27,11 +27,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ -class AclListParams -private constructor( +class AclListParams private constructor( private val objectId: String, private val objectType: ObjectType, private val endingBefore: String?, @@ -40,6 +39,7 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The id of the object the ACL applies to */ @@ -51,15 +51,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -69,9 +69,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -82,15 +82,39 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.objectId.let { + queryParams.put( + "object_id", listOf(it.toString()) + ) + } + this.objectType.let { + queryParams.put( + "object_type", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) @@ -101,12 +125,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [AclListParams]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclListParams]. */ @@ -123,67 +149,83 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclListParams: AclListParams) = apply { - objectId = aclListParams.objectId - objectType = aclListParams.objectType - endingBefore = aclListParams.endingBefore - ids = aclListParams.ids - limit = aclListParams.limit - startingAfter = aclListParams.startingAfter - additionalHeaders = aclListParams.additionalHeaders.toBuilder() - additionalQueryParams = aclListParams.additionalQueryParams.toBuilder() - } + internal fun from(aclListParams: AclListParams) = + apply { + objectId = aclListParams.objectId + objectType = aclListParams.objectType + endingBefore = aclListParams.endingBefore + ids = aclListParams.ids + limit = aclListParams.limit + startingAfter = aclListParams.startingAfter + additionalHeaders = aclListParams.additionalHeaders.toBuilder() + additionalQueryParams = aclListParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = + apply { + this.objectType = objectType + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -194,145 +236,181 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclListParams = AclListParams( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - endingBefore, - ids, - limit, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + endingBefore, + ids, + limit, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -380,9 +458,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -398,17 +478,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -429,11 +510,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -454,23 +535,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -479,16 +557,16 @@ private constructor( } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -506,19 +584,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -533,12 +611,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -548,60 +631,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index a91c07d2..edd1a180 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an acl object by its id */ -class AclRetrieveParams -private constructor( +class AclRetrieveParams private constructor( private val aclId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Acl id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,11 +43,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [AclRetrieveParams]. * * The following fields are required: + * * ```java * .aclId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclRetrieveParams]. */ @@ -59,131 +61,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclRetrieveParams: AclRetrieveParams) = apply { - aclId = aclRetrieveParams.aclId - additionalHeaders = aclRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = aclRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(aclRetrieveParams: AclRetrieveParams) = + apply { + aclId = aclRetrieveParams.aclId + additionalHeaders = aclRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = aclRetrieveParams.additionalQueryParams.toBuilder() + } /** Acl id */ - fun aclId(aclId: String) = apply { this.aclId = aclId } + fun aclId(aclId: String) = + apply { + this.aclId = aclId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclRetrieveParams = AclRetrieveParams( - checkRequired("aclId", aclId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "aclId", aclId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclRetrieveParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclRetrieveParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 4de28c65..a8215c3d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -22,14 +22,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as the one specified - * in the request, will return the existing ai_secret unmodified + * Create a new ai_secret. If there is an existing ai_secret with the same name as + * the one specified in the request, will return the existing ai_secret unmodified */ -class AiSecretCreateParams -private constructor( +class AiSecretCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the AI secret */ @@ -38,15 +38,15 @@ private constructor( fun metadata(): Optional = body.metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = body.orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(): Optional = body.secret() @@ -58,15 +58,15 @@ private constructor( fun _metadata(): JsonField = body._metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun _orgName(): JsonField = body._orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun _secret(): JsonField = body._secret() @@ -78,33 +78,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonProperty("secret") - @ExcludeMissing - private val secret: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("secret") @ExcludeMissing private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the AI secret */ @@ -113,39 +102,49 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + @JsonProperty("secret") + @ExcludeMissing + fun _secret(): JsonField = secret - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -153,19 +152,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + metadata().ifPresent { it.validate() } + orgName() + secret() + type() + validated = true } - name() - metadata().ifPresent { it.validate() } - orgName() - secret() - type() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -174,11 +174,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -192,108 +194,133 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - metadata = body.metadata - orgName = body.orgName - secret = body.secret - type = body.type - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + metadata = body.metadata + orgName = body.orgName + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: JsonField) = apply { this.secret = secret } + fun secret(secret: JsonField) = + apply { + this.secret = secret + } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun type(type: JsonField) = + apply { + this.type = type + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - metadata, - orgName, - secret, - type, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + metadata, + orgName, + secret, + type, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -302,8 +329,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -311,14 +337,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretCreateParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretCreateParams]. */ @@ -330,200 +359,263 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretCreateParams: AiSecretCreateParams) = apply { - body = aiSecretCreateParams.body.toBuilder() - additionalHeaders = aiSecretCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretCreateParams: AiSecretCreateParams) = + apply { + body = aiSecretCreateParams.body.toBuilder() + additionalHeaders = aiSecretCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretCreateParams.additionalQueryParams.toBuilder() + } /** Name of the AI secret */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the AI secret */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: String?) = apply { body.secret(secret) } + fun secret(secret: String?) = + apply { + body.secret(secret) + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: JsonField) = apply { body.secret(secret) } + fun secret(secret: JsonField) = + apply { + body.secret(secret) + } - fun type(type: String?) = apply { body.type(type) } + fun type(type: String?) = + apply { + body.type(type) + } fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { body.type(type) } + fun type(type: JsonField) = + apply { + body.type(type) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretCreateParams = AiSecretCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -532,20 +624,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -554,38 +648,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -598,15 +700,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index b62db648..3cbf2d45 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an ai_secret object by its id */ -class AiSecretDeleteParams -private constructor( +class AiSecretDeleteParams private constructor( private val aiSecretId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** AiSecret id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aiSecretId - else -> "" - } + return when (index) { + 0 -> aiSecretId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretDeleteParams]. * * The following fields are required: + * * ```java * .aiSecretId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretDeleteParams]. */ @@ -70,155 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecretDeleteParams: AiSecretDeleteParams) = apply { - aiSecretId = aiSecretDeleteParams.aiSecretId - additionalHeaders = aiSecretDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aiSecretDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(aiSecretDeleteParams: AiSecretDeleteParams) = + apply { + aiSecretId = aiSecretDeleteParams.aiSecretId + additionalHeaders = aiSecretDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aiSecretDeleteParams.additionalBodyProperties.toMutableMap() + } /** AiSecret id */ - fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } + fun aiSecretId(aiSecretId: String) = + apply { + this.aiSecretId = aiSecretId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): AiSecretDeleteParams = AiSecretDeleteParams( - checkRequired("aiSecretId", aiSecretId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "aiSecretId", aiSecretId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretDeleteParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretDeleteParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 09e2cfab..ffce1c86 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -22,20 +22,20 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Delete a single ai_secret */ -class AiSecretFindAndDeleteParams -private constructor( +class AiSecretFindAndDeleteParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the AI secret */ fun name(): String = body.name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = body.orgName() @@ -43,9 +43,9 @@ private constructor( fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -55,45 +55,44 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the AI secret */ fun name(): String = name.getRequired("name") /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -101,15 +100,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - orgName() - validated = true - } + name() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -119,11 +119,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -134,68 +136,88 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) + Body( + checkRequired( + "name", name + ), + orgName, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -204,8 +226,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -213,14 +234,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretFindAndDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretFindAndDeleteParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretFindAndDeleteParams]. */ @@ -232,174 +256,220 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretFindAndDeleteParams: AiSecretFindAndDeleteParams) = apply { - body = aiSecretFindAndDeleteParams.body.toBuilder() - additionalHeaders = aiSecretFindAndDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretFindAndDeleteParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretFindAndDeleteParams: AiSecretFindAndDeleteParams) = + apply { + body = aiSecretFindAndDeleteParams.body.toBuilder() + additionalHeaders = aiSecretFindAndDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretFindAndDeleteParams.additionalQueryParams.toBuilder() + } /** Name of the AI secret */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the AI secret */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretFindAndDeleteParams = AiSecretFindAndDeleteParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index 31ca38f9..cb07762e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.AiSecretService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ -class AiSecretListPage -private constructor( +class AiSecretListPage private constructor( private val aiSecretsService: AiSecretService, private val params: AiSecretListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretListPage && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AiSecretListPage && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ - override fun toString() = - "AiSecretListPage{aiSecretsService=$aiSecretsService, params=$params, response=$response}" + override fun toString() = "AiSecretListPage{aiSecretsService=$aiSecretsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - AiSecretListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - AiSecretListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(AiSecretListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(AiSecretListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { aiSecretsService.list(it) } + return getNextPageParams().map { aiSecretsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -84,16 +74,18 @@ private constructor( @JvmStatic fun of(aiSecretsService: AiSecretService, params: AiSecretListParams, response: Response) = - AiSecretListPage(aiSecretsService, params, response) + AiSecretListPage( + aiSecretsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -107,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [AiSecretListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -143,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: AiSecretListPage) : Iterable { + class AutoPager( + private val firstPage: AiSecretListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index 09526724..0808cf83 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.AiSecretServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ -class AiSecretListPageAsync -private constructor( +class AiSecretListPageAsync private constructor( private val aiSecretsService: AiSecretServiceAsync, private val params: AiSecretListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretListPageAsync && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AiSecretListPageAsync && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ - override fun toString() = - "AiSecretListPageAsync{aiSecretsService=$aiSecretsService, params=$params, response=$response}" + override fun toString() = "AiSecretListPageAsync{aiSecretsService=$aiSecretsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - AiSecretListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - AiSecretListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(AiSecretListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(AiSecretListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { aiSecretsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + aiSecretsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,20 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - aiSecretsService: AiSecretServiceAsync, - params: AiSecretListParams, - response: Response, - ) = AiSecretListPageAsync(aiSecretsService, params, response) + fun of(aiSecretsService: AiSecretServiceAsync, params: AiSecretListParams, response: Response) = + AiSecretListPageAsync( + aiSecretsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -112,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [AiSecretListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -150,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: AiSecretListPageAsync) { + class AutoPager( + private val firstPage: AiSecretListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (AISecret) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (AISecret) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index d41f9f78..34a3b048 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ -class AiSecretListParams -private constructor( +class AiSecretListParams private constructor( private val aiSecretName: String?, private val aiSecretType: AiSecretType?, private val endingBefore: String?, @@ -37,6 +36,7 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the ai_secret to search for */ @@ -47,15 +47,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -68,9 +68,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -81,26 +81,56 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.aiSecretName?.let { queryParams.put("ai_secret_name", listOf(it.toString())) } - this.aiSecretType?.let { queryParams.put("ai_secret_type", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.aiSecretName?.let { + queryParams.put( + "ai_secret_name", listOf(it.toString()) + ) + } + this.aiSecretType?.let { + queryParams.put( + "ai_secret_type", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): AiSecretListParams = builder().build() + @JvmStatic + fun none(): AiSecretListParams = builder().build() /** Returns a mutable builder for constructing an instance of [AiSecretListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretListParams]. */ @@ -118,78 +148,92 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretListParams: AiSecretListParams) = apply { - aiSecretName = aiSecretListParams.aiSecretName - aiSecretType = aiSecretListParams.aiSecretType - endingBefore = aiSecretListParams.endingBefore - ids = aiSecretListParams.ids - limit = aiSecretListParams.limit - orgName = aiSecretListParams.orgName - startingAfter = aiSecretListParams.startingAfter - additionalHeaders = aiSecretListParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretListParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretListParams: AiSecretListParams) = + apply { + aiSecretName = aiSecretListParams.aiSecretName + aiSecretType = aiSecretListParams.aiSecretType + endingBefore = aiSecretListParams.endingBefore + ids = aiSecretListParams.ids + limit = aiSecretListParams.limit + orgName = aiSecretListParams.orgName + startingAfter = aiSecretListParams.startingAfter + additionalHeaders = aiSecretListParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretListParams.additionalQueryParams.toBuilder() + } /** Name of the ai_secret to search for */ - fun aiSecretName(aiSecretName: String?) = apply { this.aiSecretName = aiSecretName } + fun aiSecretName(aiSecretName: String?) = + apply { + this.aiSecretName = aiSecretName + } /** Name of the ai_secret to search for */ fun aiSecretName(aiSecretName: Optional) = aiSecretName(aiSecretName.getOrNull()) - fun aiSecretType(aiSecretType: AiSecretType?) = apply { this.aiSecretType = aiSecretType } + fun aiSecretType(aiSecretType: AiSecretType?) = + apply { + this.aiSecretType = aiSecretType + } - fun aiSecretType(aiSecretType: Optional) = - aiSecretType(aiSecretType.getOrNull()) + fun aiSecretType(aiSecretType: Optional) = aiSecretType(aiSecretType.getOrNull()) fun aiSecretType(string: String) = aiSecretType(AiSecretType.ofString(string)) - fun aiSecretTypeOfStrings(strings: List) = - aiSecretType(AiSecretType.ofStrings(strings)) + fun aiSecretTypeOfStrings(strings: List) = aiSecretType(AiSecretType.ofStrings(strings)) /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -198,7 +242,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -206,141 +253,169 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretListParams = AiSecretListParams( - aiSecretName, - aiSecretType, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + aiSecretName, + aiSecretType, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = AiSecretType.Deserializer::class) @JsonSerialize(using = AiSecretType.Serializer::class) - class AiSecretType - private constructor( + class AiSecretType private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -358,19 +433,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretType && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is AiSecretType && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -385,14 +460,16 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = AiSecretType(string = string) + @JvmStatic + fun ofString(string: String) = AiSecretType(string = string) - @JvmStatic fun ofStrings(strings: List) = AiSecretType(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = AiSecretType(strings = strings) } /** - * An interface that defines how to map each variant of [AiSecretType] to a value of type - * [T]. + * An interface that defines how to map each variant of [AiSecretType] to a value + * of type [T]. */ interface Visitor { @@ -403,62 +480,58 @@ private constructor( /** * Maps an unknown variant of [AiSecretType] to a value of type [T]. * - * An instance of [AiSecretType] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [AiSecretType] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown AiSecretType: $json") + throw BraintrustInvalidDataException("Unknown AiSecretType: $json") } } internal class Deserializer : BaseDeserializer(AiSecretType::class) { override fun ObjectCodec.deserialize(node: JsonNode): AiSecretType { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return AiSecretType(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return AiSecretType(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return AiSecretType(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return AiSecretType(strings = it, _json = json) + } - return AiSecretType(_json = json) + return AiSecretType(_json = json) } } internal class Serializer : BaseSerializer(AiSecretType::class) { - override fun serialize( - value: AiSecretType, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid AiSecretType") - } + override fun serialize(value: AiSecretType, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AiSecretType") + } } } } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -476,19 +549,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -503,12 +576,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -518,60 +596,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretListParams && aiSecretName == other.aiSecretName && aiSecretType == other.aiSecretType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretListParams && aiSecretName == other.aiSecretName && aiSecretType == other.aiSecretType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 30fafd07..2f6d1f04 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will replace the existing ai_secret with the provided fields + * Create or replace ai_secret. If there is an existing ai_secret with the same + * name as the one specified in the request, will replace the existing ai_secret + * with the provided fields */ -class AiSecretReplaceParams -private constructor( +class AiSecretReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the AI secret */ @@ -38,15 +39,15 @@ private constructor( fun metadata(): Optional = body.metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = body.orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(): Optional = body.secret() @@ -58,15 +59,15 @@ private constructor( fun _metadata(): JsonField = body._metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun _orgName(): JsonField = body._orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun _secret(): JsonField = body._secret() @@ -78,33 +79,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonProperty("secret") - @ExcludeMissing - private val secret: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("secret") @ExcludeMissing private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the AI secret */ @@ -113,39 +103,49 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + @JsonProperty("secret") + @ExcludeMissing + fun _secret(): JsonField = secret - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -153,19 +153,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + metadata().ifPresent { it.validate() } + orgName() + secret() + type() + validated = true } - name() - metadata().ifPresent { it.validate() } - orgName() - secret() - type() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -174,11 +175,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -192,108 +195,133 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - metadata = body.metadata - orgName = body.orgName - secret = body.secret - type = body.type - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + metadata = body.metadata + orgName = body.orgName + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: JsonField) = apply { this.secret = secret } + fun secret(secret: JsonField) = + apply { + this.secret = secret + } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun type(type: JsonField) = + apply { + this.type = type + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - metadata, - orgName, - secret, - type, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + metadata, + orgName, + secret, + type, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -302,8 +330,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -311,14 +338,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretReplaceParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretReplaceParams]. */ @@ -330,200 +360,263 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretReplaceParams: AiSecretReplaceParams) = apply { - body = aiSecretReplaceParams.body.toBuilder() - additionalHeaders = aiSecretReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretReplaceParams: AiSecretReplaceParams) = + apply { + body = aiSecretReplaceParams.body.toBuilder() + additionalHeaders = aiSecretReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the AI secret */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the AI secret */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: String?) = apply { body.secret(secret) } + fun secret(secret: String?) = + apply { + body.secret(secret) + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: JsonField) = apply { body.secret(secret) } + fun secret(secret: JsonField) = + apply { + body.secret(secret) + } - fun type(type: String?) = apply { body.type(type) } + fun type(type: String?) = + apply { + body.type(type) + } fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { body.type(type) } + fun type(type: JsonField) = + apply { + body.type(type) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretReplaceParams = AiSecretReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -532,20 +625,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -554,38 +649,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -598,15 +701,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index 63959bb2..4319dc92 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an ai_secret object by its id */ -class AiSecretRetrieveParams -private constructor( +class AiSecretRetrieveParams private constructor( private val aiSecretId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** AiSecret id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aiSecretId - else -> "" - } + return when (index) { + 0 -> aiSecretId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretRetrieveParams]. * * The following fields are required: + * * ```java * .aiSecretId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretRetrieveParams: AiSecretRetrieveParams) = apply { - aiSecretId = aiSecretRetrieveParams.aiSecretId - additionalHeaders = aiSecretRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretRetrieveParams: AiSecretRetrieveParams) = + apply { + aiSecretId = aiSecretRetrieveParams.aiSecretId + additionalHeaders = aiSecretRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretRetrieveParams.additionalQueryParams.toBuilder() + } /** AiSecret id */ - fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } + fun aiSecretId(aiSecretId: String) = + apply { + this.aiSecretId = aiSecretId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretRetrieveParams = AiSecretRetrieveParams( - checkRequired("aiSecretId", aiSecretId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "aiSecretId", aiSecretId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretRetrieveParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretRetrieveParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index a1146def..50a0c389 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an ai_secret object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an ai_secret object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class AiSecretUpdateParams -private constructor( +class AiSecretUpdateParams private constructor( private val aiSecretId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** AiSecret id */ @@ -61,37 +61,28 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aiSecretId - else -> "" - } + return when (index) { + 0 -> aiSecretId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("secret") - @ExcludeMissing - private val secret: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("secret") @ExcludeMissing private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -103,14 +94,22 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + @JsonProperty("secret") + @ExcludeMissing + fun _secret(): JsonField = secret - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -118,24 +117,26 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + metadata().ifPresent { it.validate() } + name() + secret() + type() + validated = true } - metadata().ifPresent { it.validate() } - name() - secret() - type() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -148,19 +149,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - metadata = body.metadata - name = body.name - secret = body.secret - type = body.type - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + metadata = body.metadata + name = body.name + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Name of the AI secret */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -169,49 +174,71 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) fun secret(secret: Optional) = secret(secret.getOrNull()) - fun secret(secret: JsonField) = apply { this.secret = secret } + fun secret(secret: JsonField) = + apply { + this.secret = secret + } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun type(type: JsonField) = + apply { + this.type = type + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(metadata, name, secret, type, additionalProperties.toImmutable()) + Body( + metadata, + name, + secret, + type, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -220,8 +247,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Body{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -229,14 +255,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretUpdateParams]. * * The following fields are required: + * * ```java * .aiSecretId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretUpdateParams]. */ @@ -249,175 +278,237 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretUpdateParams: AiSecretUpdateParams) = apply { - aiSecretId = aiSecretUpdateParams.aiSecretId - body = aiSecretUpdateParams.body.toBuilder() - additionalHeaders = aiSecretUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretUpdateParams: AiSecretUpdateParams) = + apply { + aiSecretId = aiSecretUpdateParams.aiSecretId + body = aiSecretUpdateParams.body.toBuilder() + additionalHeaders = aiSecretUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretUpdateParams.additionalQueryParams.toBuilder() + } /** AiSecret id */ - fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } + fun aiSecretId(aiSecretId: String) = + apply { + this.aiSecretId = aiSecretId + } - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Name of the AI secret */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the AI secret */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the AI secret */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun secret(secret: String?) = apply { body.secret(secret) } + fun secret(secret: String?) = + apply { + body.secret(secret) + } fun secret(secret: Optional) = secret(secret.getOrNull()) - fun secret(secret: JsonField) = apply { body.secret(secret) } + fun secret(secret: JsonField) = + apply { + body.secret(secret) + } - fun type(type: String?) = apply { body.type(type) } + fun type(type: String?) = + apply { + body.type(type) + } fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { body.type(type) } + fun type(type: JsonField) = + apply { + body.type(type) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretUpdateParams = AiSecretUpdateParams( - checkRequired("aiSecretId", aiSecretId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "aiSecretId", aiSecretId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -426,20 +517,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -448,38 +541,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -492,15 +593,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretUpdateParams{aiSecretId=$aiSecretId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretUpdateParams{aiSecretId=$aiSecretId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 0b88b229..b36d8cef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -20,22 +20,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ApiKey -@JsonCreator -private constructor( +class ApiKey @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("preview_name") - @ExcludeMissing - private val previewName: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("preview_name") @ExcludeMissing private val previewName: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the api key */ @@ -56,23 +49,33 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the api key */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("preview_name") @ExcludeMissing fun _previewName(): JsonField = previewName /** Date of api key creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the user */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -80,20 +83,21 @@ private constructor( private var validated: Boolean = false - fun validate(): ApiKey = apply { - if (validated) { - return@apply + fun validate(): ApiKey = + apply { + if (validated) { + return@apply + } + + id() + name() + previewName() + created() + orgId() + userId() + validated = true } - id() - name() - previewName() - created() - orgId() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -102,13 +106,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [ApiKey]. * * The following fields are required: + * * ```java * .id() * .name() * .previewName() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKey]. */ @@ -123,31 +129,41 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKey: ApiKey) = apply { - id = apiKey.id - name = apiKey.name - previewName = apiKey.previewName - created = apiKey.created - orgId = apiKey.orgId - userId = apiKey.userId - additionalProperties = apiKey.additionalProperties.toMutableMap() - } + internal fun from(apiKey: ApiKey) = + apply { + id = apiKey.id + name = apiKey.name + previewName = apiKey.previewName + created = apiKey.created + orgId = apiKey.orgId + userId = apiKey.userId + additionalProperties = apiKey.additionalProperties.toMutableMap() + } /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) - fun previewName(previewName: JsonField) = apply { this.previewName = previewName } + fun previewName(previewName: JsonField) = + apply { + this.previewName = previewName + } /** Date of api key creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -156,7 +172,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of api key creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Unique identifier for the organization */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) @@ -165,7 +184,10 @@ private constructor( fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the user */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -174,45 +196,61 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Unique identifier for the user */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ApiKey = ApiKey( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("previewName", previewName), - created, - orgId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "previewName", previewName + ), + created, + orgId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKey && id == other.id && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ApiKey && id == other.id && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -221,6 +259,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ApiKey{id=$id, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "ApiKey{id=$id, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index a66bf130..bcde02a6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -22,23 +22,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is no - * de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same + * name. There is no de-duplication */ -class ApiKeyCreateParams -private constructor( +class ApiKeyCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the api key. Does not have to be unique */ fun name(): String = body.name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(): Optional = body.orgName() @@ -46,9 +46,9 @@ private constructor( fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -58,45 +58,44 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the api key. Does not have to be unique */ fun name(): String = name.getRequired("name") /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -104,15 +103,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - orgName() - validated = true - } + name() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -122,11 +122,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -137,68 +139,88 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the api key. Does not have to be unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key. Does not have to be unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) + Body( + checkRequired( + "name", name + ), + orgName, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -207,8 +229,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -219,11 +240,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ApiKeyCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKeyCreateParams]. */ @@ -235,174 +258,220 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = apply { - body = apiKeyCreateParams.body.toBuilder() - additionalHeaders = apiKeyCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = + apply { + body = apiKeyCreateParams.body.toBuilder() + additionalHeaders = apiKeyCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyCreateParams.additionalQueryParams.toBuilder() + } /** Name of the api key. Does not have to be unique */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the api key. Does not have to be unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ApiKeyCreateParams = ApiKeyCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ApiKeyCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ApiKeyCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index f0404eda..d1089b96 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an api_key object by its id */ -class ApiKeyDeleteParams -private constructor( +class ApiKeyDeleteParams private constructor( private val apiKeyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** ApiKey id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ApiKeyDeleteParams]. * * The following fields are required: + * * ```java * .apiKeyId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKeyDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = apply { - apiKeyId = apiKeyDeleteParams.apiKeyId - additionalHeaders = apiKeyDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = apiKeyDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = + apply { + apiKeyId = apiKeyDeleteParams.apiKeyId + additionalHeaders = apiKeyDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = apiKeyDeleteParams.additionalBodyProperties.toMutableMap() + } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } + fun apiKeyId(apiKeyId: String) = + apply { + this.apiKeyId = apiKeyId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ApiKeyDeleteParams = ApiKeyDeleteParams( - checkRequired("apiKeyId", apiKeyId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "apiKeyId", apiKeyId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyDeleteParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ApiKeyDeleteParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 0b0839e1..9f5c298c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.ApiKeyService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created - * api_keys coming first + * List out all api_keys. The api_keys are sorted by creation date, with the most + * recently-created api_keys coming first */ -class ApiKeyListPage -private constructor( +class ApiKeyListPage private constructor( private val apiKeysService: ApiKeyService, private val params: ApiKeyListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyListPage && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ApiKeyListPage && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ - override fun toString() = - "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" + override fun toString() = "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { apiKeysService.list(it) } + return getNextPageParams().map { apiKeysService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(apiKeysService: ApiKeyService, params: ApiKeyListParams, response: Response) = - ApiKeyListPage(apiKeysService, params, response) + ApiKeyListPage( + apiKeysService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ApiKeyListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ApiKeyListPage) : Iterable { + class AutoPager( + private val firstPage: ApiKeyListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index 86f19e49..4d1e49f6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.ApiKeyServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created - * api_keys coming first + * List out all api_keys. The api_keys are sorted by creation date, with the most + * recently-created api_keys coming first */ -class ApiKeyListPageAsync -private constructor( +class ApiKeyListPageAsync private constructor( private val apiKeysService: ApiKeyServiceAsync, private val params: ApiKeyListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyListPageAsync && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ApiKeyListPageAsync && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ - override fun toString() = - "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" + override fun toString() = "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { apiKeysService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + apiKeysService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(apiKeysService: ApiKeyServiceAsync, params: ApiKeyListParams, response: Response) = - ApiKeyListPageAsync(apiKeysService, params, response) + ApiKeyListPageAsync( + apiKeysService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ApiKeyListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ApiKeyListPageAsync) { + class AutoPager( + private val firstPage: ApiKeyListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (ApiKey) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (ApiKey) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 124f92d2..fdf434a9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created - * api_keys coming first + * List out all api_keys. The api_keys are sorted by creation date, with the most + * recently-created api_keys coming first */ -class ApiKeyListParams -private constructor( +class ApiKeyListParams private constructor( private val apiKeyName: String?, private val endingBefore: String?, private val ids: Ids?, @@ -36,6 +35,7 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the api_key to search for */ @@ -44,15 +44,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,51 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.apiKeyName?.let { queryParams.put("api_key_name", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.apiKeyName?.let { + queryParams.put( + "api_key_name", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ApiKeyListParams = builder().build() + @JvmStatic + fun none(): ApiKeyListParams = builder().build() /** Returns a mutable builder for constructing an instance of [ApiKeyListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKeyListParams]. */ @@ -113,19 +139,23 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(apiKeyListParams: ApiKeyListParams) = apply { - apiKeyName = apiKeyListParams.apiKeyName - endingBefore = apiKeyListParams.endingBefore - ids = apiKeyListParams.ids - limit = apiKeyListParams.limit - orgName = apiKeyListParams.orgName - startingAfter = apiKeyListParams.startingAfter - additionalHeaders = apiKeyListParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyListParams.additionalQueryParams.toBuilder() - } + internal fun from(apiKeyListParams: ApiKeyListParams) = + apply { + apiKeyName = apiKeyListParams.apiKeyName + endingBefore = apiKeyListParams.endingBefore + ids = apiKeyListParams.ids + limit = apiKeyListParams.limit + orgName = apiKeyListParams.orgName + startingAfter = apiKeyListParams.startingAfter + additionalHeaders = apiKeyListParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyListParams.additionalQueryParams.toBuilder() + } /** Name of the api_key to search for */ - fun apiKeyName(apiKeyName: String?) = apply { this.apiKeyName = apiKeyName } + fun apiKeyName(apiKeyName: String?) = + apply { + this.apiKeyName = apiKeyName + } /** Name of the api_key to search for */ fun apiKeyName(apiKeyName: Optional) = apiKeyName(apiKeyName.getOrNull()) @@ -133,47 +163,56 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -182,7 +221,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -190,144 +232,172 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ApiKeyListParams = ApiKeyListParams( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + apiKeyName, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -345,19 +415,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -372,12 +442,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -387,60 +462,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyListParams && apiKeyName == other.apiKeyName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyListParams && apiKeyName == other.apiKeyName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 50963e4d..59821a4f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an api_key object by its id */ -class ApiKeyRetrieveParams -private constructor( +class ApiKeyRetrieveParams private constructor( private val apiKeyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ApiKey id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ApiKeyRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ApiKeyRetrieveParams]. * * The following fields are required: + * * ```java * .apiKeyId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKeyRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = apply { - apiKeyId = apiKeyRetrieveParams.apiKeyId - additionalHeaders = apiKeyRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = + apply { + apiKeyId = apiKeyRetrieveParams.apiKeyId + additionalHeaders = apiKeyRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyRetrieveParams.additionalQueryParams.toBuilder() + } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } + fun apiKeyId(apiKeyId: String) = + apply { + this.apiKeyId = apiKeyId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( - checkRequired("apiKeyId", apiKeyId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "apiKeyId", apiKeyId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyRetrieveParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyRetrieveParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index fcb0d184..f69a09f1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -20,23 +20,24 @@ import java.util.Objects import java.util.Optional @NoAutoDetect -class ChatCompletionContentPartImage -@JsonCreator -private constructor( - @JsonProperty("image_url") - @ExcludeMissing - private val imageUrl: JsonField = JsonMissing.of(), +class ChatCompletionContentPartImage @JsonCreator private constructor( + @JsonProperty("image_url") @ExcludeMissing private val imageUrl: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") fun type(): Type = type.getRequired("type") - @JsonProperty("image_url") @ExcludeMissing fun _imageUrl(): JsonField = imageUrl + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -44,15 +45,16 @@ private constructor( private var validated: Boolean = false - fun validate(): ChatCompletionContentPartImage = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPartImage = + apply { + if (validated) { + return@apply + } - imageUrl().validate() - type() - validated = true - } + imageUrl().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -63,12 +65,14 @@ private constructor( * [ChatCompletionContentPartImage]. * * The following fields are required: + * * ```java * .imageUrl() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ChatCompletionContentPartImage]. */ @@ -79,67 +83,84 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chatCompletionContentPartImage: ChatCompletionContentPartImage) = apply { - imageUrl = chatCompletionContentPartImage.imageUrl - type = chatCompletionContentPartImage.type - additionalProperties = - chatCompletionContentPartImage.additionalProperties.toMutableMap() - } + internal fun from(chatCompletionContentPartImage: ChatCompletionContentPartImage) = + apply { + imageUrl = chatCompletionContentPartImage.imageUrl + type = chatCompletionContentPartImage.type + additionalProperties = chatCompletionContentPartImage.additionalProperties.toMutableMap() + } fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) - fun imageUrl(imageUrl: JsonField) = apply { this.imageUrl = imageUrl } + fun imageUrl(imageUrl: JsonField) = + apply { + this.imageUrl = imageUrl + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChatCompletionContentPartImage = ChatCompletionContentPartImage( - checkRequired("imageUrl", imageUrl), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "imageUrl", imageUrl + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class ImageUrl - @JsonCreator - private constructor( + class ImageUrl @JsonCreator private constructor( @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - private val detail: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("detail") @ExcludeMissing private val detail: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun url(): String = url.getRequired("url") fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url - @JsonProperty("detail") @ExcludeMissing fun _detail(): JsonField = detail + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail @JsonAnyGetter @ExcludeMissing @@ -147,15 +168,16 @@ private constructor( private var validated: Boolean = false - fun validate(): ImageUrl = apply { - if (validated) { - return@apply - } + fun validate(): ImageUrl = + apply { + if (validated) { + return@apply + } - url() - detail() - validated = true - } + url() + detail() + validated = true + } fun toBuilder() = Builder().from(this) @@ -165,11 +187,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ImageUrl]. * * The following fields are required: + * * ```java * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ImageUrl]. */ @@ -180,54 +204,78 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(imageUrl: ImageUrl) = apply { - url = imageUrl.url - detail = imageUrl.detail - additionalProperties = imageUrl.additionalProperties.toMutableMap() - } + internal fun from(imageUrl: ImageUrl) = + apply { + url = imageUrl.url + detail = imageUrl.detail + additionalProperties = imageUrl.additionalProperties.toMutableMap() + } fun url(url: String) = url(JsonField.of(url)) - fun url(url: JsonField) = apply { this.url = url } + fun url(url: JsonField) = + apply { + this.url = url + } fun detail(detail: Detail) = detail(JsonField.of(detail)) - fun detail(detail: JsonField) = apply { this.detail = detail } + fun detail(detail: JsonField) = + apply { + this.detail = detail + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ImageUrl = - ImageUrl(checkRequired("url", url), detail, additionalProperties.toImmutable()) + ImageUrl( + checkRequired( + "url", url + ), + detail, + additionalProperties.toImmutable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField) : Enum { + class Detail @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -251,18 +299,18 @@ private constructor( * An enum containing [Detail]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Detail] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { AUTO, LOW, HIGH, - /** - * An enum member indicating that [Detail] was instantiated with an unknown value. - */ + /** An enum member indicating that [Detail] was instantiated with an unknown value. */ _UNKNOWN, } @@ -270,8 +318,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -288,7 +336,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -304,20 +352,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Detail && value == other.value /* spotless:on */ + return /* spotless:off */ other is Detail && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -326,11 +371,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ImageUrl && url == other.url && detail == other.detail && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ImageUrl && url == other.url && detail == other.detail && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -339,21 +384,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -364,16 +412,18 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - IMAGE_URL + IMAGE_URL, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -383,11 +433,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -398,11 +448,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -413,23 +463,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -438,11 +485,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPartImage && imageUrl == other.imageUrl && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPartImage && imageUrl == other.imageUrl && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -451,6 +498,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ChatCompletionContentPartImage{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "ChatCompletionContentPartImage{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index c4b1ce91..444bd3c7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -20,21 +20,24 @@ import java.util.Objects import java.util.Optional @NoAutoDetect -class ChatCompletionContentPartText -@JsonCreator -private constructor( +class ChatCompletionContentPartText @JsonCreator private constructor( @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") fun text(): Optional = Optional.ofNullable(text.getNullable("text")) - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + @JsonProperty("text") + @ExcludeMissing + fun _text(): JsonField = text @JsonAnyGetter @ExcludeMissing @@ -42,15 +45,16 @@ private constructor( private var validated: Boolean = false - fun validate(): ChatCompletionContentPartText = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPartText = + apply { + if (validated) { + return@apply + } - type() - text() - validated = true - } + type() + text() + validated = true + } fun toBuilder() = Builder().from(this) @@ -61,11 +65,13 @@ private constructor( * [ChatCompletionContentPartText]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ChatCompletionContentPartText]. */ @@ -76,58 +82,78 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chatCompletionContentPartText: ChatCompletionContentPartText) = apply { - type = chatCompletionContentPartText.type - text = chatCompletionContentPartText.text - additionalProperties = chatCompletionContentPartText.additionalProperties.toMutableMap() - } + internal fun from(chatCompletionContentPartText: ChatCompletionContentPartText) = + apply { + type = chatCompletionContentPartText.type + text = chatCompletionContentPartText.text + additionalProperties = chatCompletionContentPartText.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun text(text: String) = text(JsonField.of(text)) - fun text(text: JsonField) = apply { this.text = text } + fun text(text: JsonField) = + apply { + this.text = text + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChatCompletionContentPartText = ChatCompletionContentPartText( - checkRequired("type", type), - text, - additionalProperties.toImmutable(), + checkRequired( + "type", type + ), + text, + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -138,16 +164,18 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - TEXT + TEXT, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -157,11 +185,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -172,11 +200,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -187,23 +215,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -212,11 +237,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPartText && type == other.type && text == other.text && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPartText && type == other.type && text == other.text && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -225,6 +250,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ChatCompletionContentPartText{type=$type, text=$text, additionalProperties=$additionalProperties}" + override fun toString() = "ChatCompletionContentPartText{type=$type, text=$text, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 3ae3ad83..66d851d6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -19,15 +19,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class ChatCompletionMessageToolCall -@JsonCreator -private constructor( +class ChatCompletionMessageToolCall @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("function") - @ExcludeMissing - private val function: JsonField = JsonMissing.of(), + @JsonProperty("function") @ExcludeMissing private val function: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun id(): String = id.getRequired("id") @@ -36,11 +33,17 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id - @JsonProperty("function") @ExcludeMissing fun _function(): JsonField = function + @JsonProperty("function") + @ExcludeMissing + fun _function(): JsonField = function - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -48,16 +51,17 @@ private constructor( private var validated: Boolean = false - fun validate(): ChatCompletionMessageToolCall = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionMessageToolCall = + apply { + if (validated) { + return@apply + } - id() - function().validate() - type() - validated = true - } + id() + function().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -68,13 +72,15 @@ private constructor( * [ChatCompletionMessageToolCall]. * * The following fields are required: + * * ```java * .id() * .function() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ChatCompletionMessageToolCall]. */ @@ -86,74 +92,95 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chatCompletionMessageToolCall: ChatCompletionMessageToolCall) = apply { - id = chatCompletionMessageToolCall.id - function = chatCompletionMessageToolCall.function - type = chatCompletionMessageToolCall.type - additionalProperties = chatCompletionMessageToolCall.additionalProperties.toMutableMap() - } + internal fun from(chatCompletionMessageToolCall: ChatCompletionMessageToolCall) = + apply { + id = chatCompletionMessageToolCall.id + function = chatCompletionMessageToolCall.function + type = chatCompletionMessageToolCall.type + additionalProperties = chatCompletionMessageToolCall.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } fun function(function: Function) = function(JsonField.of(function)) - fun function(function: JsonField) = apply { this.function = function } + fun function(function: JsonField) = + apply { + this.function = function + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChatCompletionMessageToolCall = ChatCompletionMessageToolCall( - checkRequired("id", id), - checkRequired("function", function), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "function", function + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("arguments") - @ExcludeMissing - private val arguments: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("arguments") @ExcludeMissing private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun arguments(): String = arguments.getRequired("arguments") fun name(): String = name.getRequired("name") - @JsonProperty("arguments") @ExcludeMissing fun _arguments(): JsonField = arguments + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments(): JsonField = arguments - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -161,15 +188,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - arguments() - name() - validated = true - } + arguments() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -179,12 +207,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .arguments() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -195,53 +225,71 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - arguments = function.arguments - name = function.name - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + arguments = function.arguments + name = function.name + additionalProperties = function.additionalProperties.toMutableMap() + } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - fun arguments(arguments: JsonField) = apply { this.arguments = arguments } + fun arguments(arguments: JsonField) = + apply { + this.arguments = arguments + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun name(name: JsonField) = + apply { + this.name = name + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("arguments", arguments), - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "arguments", arguments + ), + checkRequired( + "name", name + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -250,21 +298,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -275,16 +326,18 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -294,11 +347,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -309,11 +362,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -324,23 +377,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -349,11 +399,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionMessageToolCall && id == other.id && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionMessageToolCall && id == other.id && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -362,6 +412,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ChatCompletionMessageToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "ChatCompletionMessageToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index e5712817..d0ec91d3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -31,22 +31,13 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class CodeBundle -@JsonCreator -private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), +class CodeBundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") @@ -58,16 +49,22 @@ private constructor( /** A preview of the code */ fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId(): JsonField = bundleId + @JsonProperty("bundle_id") + @ExcludeMissing + fun _bundleId(): JsonField = bundleId - @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview(): JsonField = preview @JsonAnyGetter @ExcludeMissing @@ -75,17 +72,18 @@ private constructor( private var validated: Boolean = false - fun validate(): CodeBundle = apply { - if (validated) { - return@apply - } + fun validate(): CodeBundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + validated = true + } fun toBuilder() = Builder().from(this) @@ -95,13 +93,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [CodeBundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() * .runtimeContext() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [CodeBundle]. */ @@ -114,32 +114,39 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(codeBundle: CodeBundle) = apply { - bundleId = codeBundle.bundleId - location = codeBundle.location - runtimeContext = codeBundle.runtimeContext - preview = codeBundle.preview - additionalProperties = codeBundle.additionalProperties.toMutableMap() - } + internal fun from(codeBundle: CodeBundle) = + apply { + bundleId = codeBundle.bundleId + location = codeBundle.location + runtimeContext = codeBundle.runtimeContext + preview = codeBundle.preview + additionalProperties = codeBundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } fun location(location: Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { this.location = location } + fun location(location: JsonField) = + apply { + this.location = location + } fun location(experiment: Location.Experiment) = location(Location.ofExperiment(experiment)) fun location(function: Location.Function) = location(Location.ofFunction(function)) - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } /** A preview of the code */ fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) @@ -148,44 +155,60 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): CodeBundle = CodeBundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Location.Deserializer::class) @JsonSerialize(using = Location.Serializer::class) - class Location - private constructor( + class Location private constructor( private val experiment: Experiment? = null, private val function: Function? = null, private val _json: JsonValue? = null, + ) { fun experiment(): Optional = Optional.ofNullable(experiment) @@ -203,40 +226,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - experiment != null -> visitor.visitExperiment(experiment) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + experiment != null -> visitor.visitExperiment(experiment) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Location = apply { - if (validated) { - return@apply - } + fun validate(): Location = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitExperiment(experiment: Experiment) { - experiment.validate() + experiment.validate() } override fun visitFunction(function: Function) { - function.validate() + function.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Location && experiment == other.experiment && function == other.function /* spotless:on */ + return /* spotless:off */ other is Location && experiment == other.experiment && function == other.function /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experiment, function) /* spotless:on */ @@ -251,13 +273,16 @@ private constructor( companion object { - @JvmStatic fun ofExperiment(experiment: Experiment) = Location(experiment = experiment) + @JvmStatic + fun ofExperiment(experiment: Experiment) = Location(experiment = experiment) - @JvmStatic fun ofFunction(function: Function) = Location(function = function) + @JvmStatic + fun ofFunction(function: Function) = Location(function = function) } /** - * An interface that defines how to map each variant of [Location] to a value of type [T]. + * An interface that defines how to map each variant of [Location] to a value of + * type [T]. */ interface Visitor { @@ -268,67 +293,53 @@ private constructor( /** * Maps an unknown variant of [Location] to a value of type [T]. * - * An instance of [Location] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Location] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Location: $json") + throw BraintrustInvalidDataException("Unknown Location: $json") } } internal class Deserializer : BaseDeserializer(Location::class) { override fun ObjectCodec.deserialize(node: JsonNode): Location { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Location(experiment = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Location(function = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Location(experiment = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Location(function = it, _json = json) + } - return Location(_json = json) + return Location(_json = json) } } internal class Serializer : BaseSerializer(Location::class) { - override fun serialize( - value: Location, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.experiment != null -> generator.writeObject(value.experiment) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Location") - } + override fun serialize(value: Location, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.experiment != null -> generator.writeObject(value.experiment) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Location") + } } } @NoAutoDetect - class Experiment - @JsonCreator - private constructor( - @JsonProperty("eval_name") - @ExcludeMissing - private val evalName: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Experiment @JsonCreator private constructor( + @JsonProperty("eval_name") @ExcludeMissing private val evalName: JsonField = JsonMissing.of(), + @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun evalName(): String = evalName.getRequired("eval_name") @@ -337,13 +348,17 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("eval_name") @ExcludeMissing fun _evalName(): JsonField = evalName + @JsonProperty("eval_name") + @ExcludeMissing + fun _evalName(): JsonField = evalName @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -351,16 +366,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Experiment = apply { - if (validated) { - return@apply - } + fun validate(): Experiment = + apply { + if (validated) { + return@apply + } - evalName() - position().validate() - type() - validated = true - } + evalName() + position().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -370,13 +386,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Experiment]. * * The following fields are required: + * * ```java * .evalName() * .position() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Experiment]. */ @@ -388,20 +406,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experiment: Experiment) = apply { - evalName = experiment.evalName - position = experiment.position - type = experiment.type - additionalProperties = experiment.additionalProperties.toMutableMap() - } + internal fun from(experiment: Experiment) = + apply { + evalName = experiment.evalName + position = experiment.position + type = experiment.type + additionalProperties = experiment.additionalProperties.toMutableMap() + } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) - fun evalName(evalName: JsonField) = apply { this.evalName = evalName } + fun evalName(evalName: JsonField) = + apply { + this.evalName = evalName + } fun position(position: Position) = position(JsonField.of(position)) - fun position(position: JsonField) = apply { this.position = position } + fun position(position: JsonField) = + apply { + this.position = position + } fun position(type: Position.Type) = position(Position.ofType(type)) @@ -409,46 +434,59 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Experiment = Experiment( - checkRequired("evalName", evalName), - checkRequired("position", position), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "evalName", evalName + ), + checkRequired( + "position", position + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position - private constructor( + class Position private constructor( private val type: Type? = null, private val scorer: Scorer? = null, private val _json: JsonValue? = null, + ) { fun type(): Optional = Optional.ofNullable(type) @@ -466,40 +504,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - scorer != null -> visitor.visitScorer(scorer) - else -> visitor.unknown(_json) - } + return when { + type != null -> visitor.visitType(type) + scorer != null -> visitor.visitScorer(scorer) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Position = apply { - if (validated) { - return@apply - } + fun validate(): Position = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitType(type: Type) { - type.validate() + type.validate() } override fun visitScorer(scorer: Scorer) { - scorer.validate() + scorer.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Position && type == other.type && scorer == other.scorer /* spotless:on */ + return /* spotless:off */ other is Position && type == other.type && scorer == other.scorer /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(type, scorer) /* spotless:on */ @@ -514,9 +551,11 @@ private constructor( companion object { - @JvmStatic fun ofType(type: Type) = Position(type = type) + @JvmStatic + fun ofType(type: Type) = Position(type = type) - @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + @JvmStatic + fun ofScorer(scorer: Scorer) = Position(scorer = scorer) } /** @@ -532,66 +571,58 @@ private constructor( /** * Maps an unknown variant of [Position] to a value of type [T]. * - * An instance of [Position] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * An instance of [Position] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } internal class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(scorer = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Position(type = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Position(scorer = it, _json = json) + } - return Position(_json = json) + return Position(_json = json) } } internal class Serializer : BaseSerializer(Position::class) { - override fun serialize( - value: Position, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.type != null -> generator.writeObject(value.type) - value.scorer != null -> generator.writeObject(value.scorer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + override fun serialize(value: Position, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.type != null -> generator.writeObject(value.type) + value.scorer != null -> generator.writeObject(value.scorer) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") + } } } @NoAutoDetect - class Type - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Type @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): InnerType = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -599,14 +630,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Type = apply { - if (validated) { - return@apply - } + fun validate(): Type = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -616,29 +648,34 @@ private constructor( * Returns a mutable builder for constructing an instance of [Type]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Type]. */ class Builder internal constructor() { private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties = type.additionalProperties.toMutableMap() - } + internal fun from(type: Type) = + apply { + this.type = type.type + additionalProperties = type.additionalProperties.toMutableMap() + } fun type(type: InnerType) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -646,37 +683,46 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Type = - Type(checkRequired("type", type), additionalProperties.toImmutable()) + Type( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class InnerType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class InnerType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -690,25 +736,25 @@ private constructor( /** An enum containing [InnerType]'s known values. */ enum class Known { - TASK + TASK, } /** - * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InnerType] can contain an unknown value in a couple of cases: * - * An instance of [InnerType] can contain an unknown value in a couple of - * cases: * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { TASK, /** - * An enum member indicating that [InnerType] was instantiated with an - * unknown value. + * An enum member indicating that [InnerType] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -717,8 +763,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -729,41 +775,35 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown InnerType: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown InnerType: $value") } /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InnerType && value == other.value /* spotless:on */ + return /* spotless:off */ other is InnerType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -772,11 +812,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Type && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -785,31 +825,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Scorer - @JsonCreator - private constructor( - @JsonProperty("index") - @ExcludeMissing - private val index: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Scorer @JsonCreator private constructor( + @JsonProperty("index") @ExcludeMissing private val index: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun index(): Long = index.getRequired("index") fun type(): Type = type.getRequired("type") - @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + @JsonProperty("index") + @ExcludeMissing + fun _index(): JsonField = index - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -817,15 +854,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Scorer = apply { - if (validated) { - return@apply - } + fun validate(): Scorer = + apply { + if (validated) { + return@apply + } - index() - type() - validated = true - } + index() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -835,12 +873,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Scorer]. * * The following fields are required: + * * ```java * .index() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scorer]. */ @@ -848,23 +888,29 @@ private constructor( private var index: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scorer: Scorer) = apply { - index = scorer.index - type = scorer.type - additionalProperties = scorer.additionalProperties.toMutableMap() - } + internal fun from(scorer: Scorer) = + apply { + index = scorer.index + type = scorer.type + additionalProperties = scorer.additionalProperties.toMutableMap() + } fun index(index: Long) = index(JsonField.of(index)) - fun index(index: JsonField) = apply { this.index = index } + fun index(index: JsonField) = + apply { + this.index = index + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -872,41 +918,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scorer = Scorer( - checkRequired("index", index), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "index", index + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -920,25 +975,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - SCORER + SCORER, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { SCORER, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -946,8 +999,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -958,11 +1011,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -973,23 +1026,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -998,11 +1048,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scorer && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scorer && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1011,13 +1061,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Scorer{index=$index, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Scorer{index=$index, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1027,7 +1078,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1038,23 +1090,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - EXPERIMENT + EXPERIMENT, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { EXPERIMENT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1078,7 +1130,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1093,19 +1145,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1114,11 +1163,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Experiment && evalName == other.evalName && position == other.position && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && evalName == other.evalName && position == other.position && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1127,31 +1176,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Experiment{evalName=$evalName, position=$position, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Experiment{evalName=$evalName, position=$position, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("index") - @ExcludeMissing - private val index: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("index") @ExcludeMissing private val index: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun index(): Long = index.getRequired("index") fun type(): Type = type.getRequired("type") - @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + @JsonProperty("index") + @ExcludeMissing + fun _index(): JsonField = index - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1159,15 +1205,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - index() - type() - validated = true - } + index() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1177,12 +1224,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .index() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -1193,52 +1242,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - index = function.index - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + index = function.index + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun index(index: Long) = index(JsonField.of(index)) - fun index(index: JsonField) = apply { this.index = index } + fun index(index: JsonField) = + apply { + this.index = index + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("index", index), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "index", index + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1248,7 +1314,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1259,23 +1326,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { FUNCTION, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1299,7 +1366,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1314,19 +1381,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1335,11 +1399,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1348,32 +1412,29 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{index=$index, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Function{index=$index, type=$type, additionalProperties=$additionalProperties}" } } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1381,15 +1442,16 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1399,12 +1461,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1415,59 +1479,80 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { this.runtime = runtime } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Runtime @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1488,17 +1573,17 @@ private constructor( * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Runtime] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an unknown value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1506,8 +1591,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1523,7 +1608,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1538,20 +1623,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1560,11 +1642,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1573,16 +1655,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is CodeBundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CodeBundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1591,6 +1672,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "CodeBundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, additionalProperties=$additionalProperties}" + override fun toString() = "CodeBundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index ba204bc6..e27dc4bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -20,23 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class CreateApiKeyOutput -@JsonCreator -private constructor( +class CreateApiKeyOutput @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("key") @ExcludeMissing private val key: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("preview_name") - @ExcludeMissing - private val previewName: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("preview_name") @ExcludeMissing private val previewName: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the api key */ @@ -60,26 +53,38 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** The raw API key. It will only be exposed this one time */ - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + @JsonProperty("key") + @ExcludeMissing + fun _key(): JsonField = key /** Name of the api key */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("preview_name") @ExcludeMissing fun _previewName(): JsonField = previewName /** Date of api key creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the user */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -87,21 +92,22 @@ private constructor( private var validated: Boolean = false - fun validate(): CreateApiKeyOutput = apply { - if (validated) { - return@apply + fun validate(): CreateApiKeyOutput = + apply { + if (validated) { + return@apply + } + + id() + key() + name() + previewName() + created() + orgId() + userId() + validated = true } - id() - key() - name() - previewName() - created() - orgId() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -110,6 +116,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [CreateApiKeyOutput]. * * The following fields are required: + * * ```java * .id() * .key() @@ -117,7 +124,8 @@ private constructor( * .previewName() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [CreateApiKeyOutput]. */ @@ -133,38 +141,51 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(createApiKeyOutput: CreateApiKeyOutput) = apply { - id = createApiKeyOutput.id - key = createApiKeyOutput.key - name = createApiKeyOutput.name - previewName = createApiKeyOutput.previewName - created = createApiKeyOutput.created - orgId = createApiKeyOutput.orgId - userId = createApiKeyOutput.userId - additionalProperties = createApiKeyOutput.additionalProperties.toMutableMap() - } + internal fun from(createApiKeyOutput: CreateApiKeyOutput) = + apply { + id = createApiKeyOutput.id + key = createApiKeyOutput.key + name = createApiKeyOutput.name + previewName = createApiKeyOutput.previewName + created = createApiKeyOutput.created + orgId = createApiKeyOutput.orgId + userId = createApiKeyOutput.userId + additionalProperties = createApiKeyOutput.additionalProperties.toMutableMap() + } /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** The raw API key. It will only be exposed this one time */ fun key(key: String) = key(JsonField.of(key)) /** The raw API key. It will only be exposed this one time */ - fun key(key: JsonField) = apply { this.key = key } + fun key(key: JsonField) = + apply { + this.key = key + } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) - fun previewName(previewName: JsonField) = apply { this.previewName = previewName } + fun previewName(previewName: JsonField) = + apply { + this.previewName = previewName + } /** Date of api key creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -173,7 +194,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of api key creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Unique identifier for the organization */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) @@ -182,7 +206,10 @@ private constructor( fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the user */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -191,46 +218,64 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Unique identifier for the user */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): CreateApiKeyOutput = CreateApiKeyOutput( - checkRequired("id", id), - checkRequired("key", key), - checkRequired("name", name), - checkRequired("previewName", previewName), - created, - orgId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "key", key + ), + checkRequired( + "name", name + ), + checkRequired( + "previewName", previewName + ), + created, + orgId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is CreateApiKeyOutput && id == other.id && key == other.key && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CreateApiKeyOutput && id == other.id && key == other.key && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -239,6 +284,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "CreateApiKeyOutput{id=$id, key=$key, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "CreateApiKeyOutput{id=$id, key=$key, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index b6a00359..d2255c0a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -18,34 +18,27 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class CrossObjectInsertResponse -@JsonCreator -private constructor( - @JsonProperty("dataset") - @ExcludeMissing - private val dataset: JsonField = JsonMissing.of(), - @JsonProperty("experiment") - @ExcludeMissing - private val experiment: JsonField = JsonMissing.of(), - @JsonProperty("project_logs") - @ExcludeMissing - private val projectLogs: JsonField = JsonMissing.of(), +class CrossObjectInsertResponse @JsonCreator private constructor( + @JsonProperty("dataset") @ExcludeMissing private val dataset: JsonField = JsonMissing.of(), + @JsonProperty("experiment") @ExcludeMissing private val experiment: JsonField = JsonMissing.of(), + @JsonProperty("project_logs") @ExcludeMissing private val projectLogs: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A mapping from dataset id to row ids for inserted `events` */ fun dataset(): Optional = Optional.ofNullable(dataset.getNullable("dataset")) /** A mapping from experiment id to row ids for inserted `events` */ - fun experiment(): Optional = - Optional.ofNullable(experiment.getNullable("experiment")) + fun experiment(): Optional = Optional.ofNullable(experiment.getNullable("experiment")) /** A mapping from project id to row ids for inserted `events` */ - fun projectLogs(): Optional = - Optional.ofNullable(projectLogs.getNullable("project_logs")) + fun projectLogs(): Optional = Optional.ofNullable(projectLogs.getNullable("project_logs")) /** A mapping from dataset id to row ids for inserted `events` */ - @JsonProperty("dataset") @ExcludeMissing fun _dataset(): JsonField = dataset + @JsonProperty("dataset") + @ExcludeMissing + fun _dataset(): JsonField = dataset /** A mapping from experiment id to row ids for inserted `events` */ @JsonProperty("experiment") @@ -63,25 +56,28 @@ private constructor( private var validated: Boolean = false - fun validate(): CrossObjectInsertResponse = apply { - if (validated) { - return@apply - } + fun validate(): CrossObjectInsertResponse = + apply { + if (validated) { + return@apply + } - dataset().ifPresent { it.validate() } - experiment().ifPresent { it.validate() } - projectLogs().ifPresent { it.validate() } - validated = true - } + dataset().ifPresent { it.validate() } + experiment().ifPresent { it.validate() } + projectLogs().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [CrossObjectInsertResponse]. + * Returns a mutable builder for constructing an instance of + * [CrossObjectInsertResponse]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [CrossObjectInsertResponse]. */ @@ -93,12 +89,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(crossObjectInsertResponse: CrossObjectInsertResponse) = apply { - dataset = crossObjectInsertResponse.dataset - experiment = crossObjectInsertResponse.experiment - projectLogs = crossObjectInsertResponse.projectLogs - additionalProperties = crossObjectInsertResponse.additionalProperties.toMutableMap() - } + internal fun from(crossObjectInsertResponse: CrossObjectInsertResponse) = + apply { + dataset = crossObjectInsertResponse.dataset + experiment = crossObjectInsertResponse.experiment + projectLogs = crossObjectInsertResponse.projectLogs + additionalProperties = crossObjectInsertResponse.additionalProperties.toMutableMap() + } /** A mapping from dataset id to row ids for inserted `events` */ fun dataset(dataset: Dataset?) = dataset(JsonField.ofNullable(dataset)) @@ -107,7 +104,10 @@ private constructor( fun dataset(dataset: Optional) = dataset(dataset.getOrNull()) /** A mapping from dataset id to row ids for inserted `events` */ - fun dataset(dataset: JsonField) = apply { this.dataset = dataset } + fun dataset(dataset: JsonField) = + apply { + this.dataset = dataset + } /** A mapping from experiment id to row ids for inserted `events` */ fun experiment(experiment: Experiment?) = experiment(JsonField.ofNullable(experiment)) @@ -116,7 +116,10 @@ private constructor( fun experiment(experiment: Optional) = experiment(experiment.getOrNull()) /** A mapping from experiment id to row ids for inserted `events` */ - fun experiment(experiment: JsonField) = apply { this.experiment = experiment } + fun experiment(experiment: JsonField) = + apply { + this.experiment = experiment + } /** A mapping from project id to row ids for inserted `events` */ fun projectLogs(projectLogs: ProjectLogs?) = projectLogs(JsonField.ofNullable(projectLogs)) @@ -125,45 +128,51 @@ private constructor( fun projectLogs(projectLogs: Optional) = projectLogs(projectLogs.getOrNull()) /** A mapping from project id to row ids for inserted `events` */ - fun projectLogs(projectLogs: JsonField) = apply { - this.projectLogs = projectLogs - } + fun projectLogs(projectLogs: JsonField) = + apply { + this.projectLogs = projectLogs + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): CrossObjectInsertResponse = CrossObjectInsertResponse( - dataset, - experiment, - projectLogs, - additionalProperties.toImmutable(), + dataset, + experiment, + projectLogs, + additionalProperties.toImmutable(), ) } /** A mapping from dataset id to row ids for inserted `events` */ @NoAutoDetect - class Dataset - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Dataset @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -172,20 +181,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Dataset = apply { - if (validated) { - return@apply - } + fun validate(): Dataset = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Dataset]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Dataset]. */ @@ -194,38 +205,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dataset: Dataset) = apply { - additionalProperties = dataset.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(dataset: Dataset) = + apply { + additionalProperties = dataset.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Dataset = Dataset(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Dataset && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Dataset && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -239,11 +258,9 @@ private constructor( /** A mapping from experiment id to row ids for inserted `events` */ @NoAutoDetect - class Experiment - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Experiment @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -252,20 +269,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Experiment = apply { - if (validated) { - return@apply - } + fun validate(): Experiment = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Experiment]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Experiment]. */ @@ -274,38 +293,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experiment: Experiment) = apply { - additionalProperties = experiment.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(experiment: Experiment) = + apply { + additionalProperties = experiment.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Experiment = Experiment(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Experiment && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -319,11 +346,9 @@ private constructor( /** A mapping from project id to row ids for inserted `events` */ @NoAutoDetect - class ProjectLogs - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class ProjectLogs @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -332,20 +357,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectLogs = apply { - if (validated) { - return@apply - } + fun validate(): ProjectLogs = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ProjectLogs]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogs]. */ @@ -354,38 +381,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectLogs: ProjectLogs) = apply { - additionalProperties = projectLogs.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(projectLogs: ProjectLogs) = + apply { + additionalProperties = projectLogs.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectLogs = ProjectLogs(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogs && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogs && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -398,11 +433,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is CrossObjectInsertResponse && dataset == other.dataset && experiment == other.experiment && projectLogs == other.projectLogs && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CrossObjectInsertResponse && dataset == other.dataset && experiment == other.experiment && projectLogs == other.projectLogs && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -411,6 +446,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "CrossObjectInsertResponse{dataset=$dataset, experiment=$experiment, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" + override fun toString() = "CrossObjectInsertResponse{dataset=$dataset, experiment=$experiment, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index 25297bb3..fc846ec3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -18,13 +18,10 @@ import java.util.Objects /** Summary of a dataset's data */ @NoAutoDetect -class DataSummary -@JsonCreator -private constructor( - @JsonProperty("total_records") - @ExcludeMissing - private val totalRecords: JsonField = JsonMissing.of(), +class DataSummary @JsonCreator private constructor( + @JsonProperty("total_records") @ExcludeMissing private val totalRecords: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Total number of records in the dataset */ @@ -41,14 +38,15 @@ private constructor( private var validated: Boolean = false - fun validate(): DataSummary = apply { - if (validated) { - return@apply - } + fun validate(): DataSummary = + apply { + if (validated) { + return@apply + } - totalRecords() - validated = true - } + totalRecords() + validated = true + } fun toBuilder() = Builder().from(this) @@ -58,11 +56,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DataSummary]. * * The following fields are required: + * * ```java * .totalRecords() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DataSummary]. */ @@ -72,49 +72,61 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dataSummary: DataSummary) = apply { - totalRecords = dataSummary.totalRecords - additionalProperties = dataSummary.additionalProperties.toMutableMap() - } + internal fun from(dataSummary: DataSummary) = + apply { + totalRecords = dataSummary.totalRecords + additionalProperties = dataSummary.additionalProperties.toMutableMap() + } /** Total number of records in the dataset */ fun totalRecords(totalRecords: Long) = totalRecords(JsonField.of(totalRecords)) /** Total number of records in the dataset */ - fun totalRecords(totalRecords: JsonField) = apply { this.totalRecords = totalRecords } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun totalRecords(totalRecords: JsonField) = + apply { + this.totalRecords = totalRecords + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): DataSummary = DataSummary( - checkRequired("totalRecords", totalRecords), - additionalProperties.toImmutable(), + checkRequired( + "totalRecords", totalRecords + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DataSummary && totalRecords == other.totalRecords && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DataSummary && totalRecords == other.totalRecords && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -123,6 +135,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" + override fun toString() = "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index 6a1818a9..6a36285e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -20,30 +20,17 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Dataset -@JsonCreator -private constructor( +class Dataset @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the dataset */ @@ -59,12 +46,10 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of dataset deletion, or null if the dataset is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the dataset */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -73,16 +58,24 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the dataset */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Date of dataset creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of dataset deletion, or null if the dataset is still active */ @JsonProperty("deleted_at") @@ -90,13 +83,19 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the dataset */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Identifies the user who created the dataset */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -104,21 +103,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Dataset = apply { - if (validated) { - return@apply - } + fun validate(): Dataset = + apply { + if (validated) { + return@apply + } - id() - name() - projectId() - created() - deletedAt() - description() - metadata().ifPresent { it.validate() } - userId() - validated = true - } + id() + name() + projectId() + created() + deletedAt() + description() + metadata().ifPresent { it.validate() } + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -128,13 +128,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Dataset]. * * The following fields are required: + * * ```java * .id() * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Dataset]. */ @@ -151,35 +153,45 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dataset: Dataset) = apply { - id = dataset.id - name = dataset.name - projectId = dataset.projectId - created = dataset.created - deletedAt = dataset.deletedAt - description = dataset.description - metadata = dataset.metadata - userId = dataset.userId - additionalProperties = dataset.additionalProperties.toMutableMap() - } + internal fun from(dataset: Dataset) = + apply { + id = dataset.id + name = dataset.name + projectId = dataset.projectId + created = dataset.created + deletedAt = dataset.deletedAt + description = dataset.description + metadata = dataset.metadata + userId = dataset.userId + additionalProperties = dataset.additionalProperties.toMutableMap() + } /** Unique identifier for the dataset */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the dataset */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Date of dataset creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -188,7 +200,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of dataset creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of dataset deletion, or null if the dataset is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -197,7 +212,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of dataset deletion, or null if the dataset is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -206,7 +224,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -215,7 +236,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Identifies the user who created the dataset */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -224,48 +248,62 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the dataset */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Dataset = Dataset( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - created, - deletedAt, - description, - metadata, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + created, + deletedAt, + description, + metadata, + userId, + additionalProperties.toImmutable(), ) } /** User-controlled metadata about the dataset */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -274,20 +312,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -296,38 +336,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -340,11 +388,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Dataset && id == other.id && name == other.name && projectId == other.projectId && created == other.created && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Dataset && id == other.id && name == other.name && projectId == other.projectId && created == other.created && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -353,6 +401,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Dataset{id=$id, name=$name, projectId=$projectId, created=$created, deletedAt=$deletedAt, description=$description, metadata=$metadata, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Dataset{id=$id, name=$name, projectId=$projectId, created=$created, deletedAt=$deletedAt, description=$description, metadata=$metadata, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index be5669c3..7930ddda 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new dataset. If there is an existing dataset in the project with the same name as the - * one specified in the request, will return the existing dataset unmodified + * Create a new dataset. If there is an existing dataset in the project with the + * same name as the one specified in the request, will return the existing dataset + * unmodified */ -class DatasetCreateParams -private constructor( +class DatasetCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the dataset. Within a project, dataset names are unique */ @@ -62,30 +63,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the dataset. Within a project, dataset names are unique */ @@ -95,17 +87,20 @@ private constructor( fun projectId(): String = projectId.getRequired("project_id") /** Textual description of the dataset */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Textual description of the dataset */ @JsonProperty("description") @@ -113,7 +108,9 @@ private constructor( fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing @@ -121,18 +118,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + description() + metadata().ifPresent { it.validate() } + validated = true } - name() - projectId() - description() - metadata().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -141,12 +139,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -159,25 +159,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - description = body.description - metadata = body.metadata - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + description = body.description + metadata = body.metadata + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -186,9 +193,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -197,43 +205,57 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - description, - metadata, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + description, + metadata, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -242,8 +264,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -254,12 +275,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetCreateParams]. */ @@ -271,174 +294,231 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetCreateParams: DatasetCreateParams) = apply { - body = datasetCreateParams.body.toBuilder() - additionalHeaders = datasetCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetCreateParams: DatasetCreateParams) = + apply { + body = datasetCreateParams.body.toBuilder() + additionalHeaders = datasetCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetCreateParams.additionalQueryParams.toBuilder() + } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Textual description of the dataset */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the dataset */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetCreateParams = DatasetCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the dataset */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -447,20 +527,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -469,38 +551,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -513,15 +603,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 8f43631d..708741d2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a dataset object by its id */ -class DatasetDeleteParams -private constructor( +class DatasetDeleteParams private constructor( private val datasetId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Dataset id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetDeleteParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetDeleteParams: DatasetDeleteParams) = apply { - datasetId = datasetDeleteParams.datasetId - additionalHeaders = datasetDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = datasetDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(datasetDeleteParams: DatasetDeleteParams) = + apply { + datasetId = datasetDeleteParams.datasetId + additionalHeaders = datasetDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = datasetDeleteParams.additionalBodyProperties.toMutableMap() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): DatasetDeleteParams = DatasetDeleteParams( - checkRequired("datasetId", datasetId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "datasetId", datasetId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetDeleteParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetDeleteParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 9552e3d7..65781e58 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -23,55 +23,35 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class DatasetEvent -@JsonCreator -private constructor( +class DatasetEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("is_root") - @ExcludeMissing - private val isRoot: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the dataset (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the dataset (see the `version` + * parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -88,30 +68,38 @@ private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier used to link different dataset events together as part of a full trace. - * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on - * tracing + * A unique identifier used to link different dataset events together as part of a + * full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable + * object) + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** Whether this span is a root span */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -122,54 +110,78 @@ private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the dataset (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the dataset (see the `version` + * parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField = datasetId /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** A unique identifier for the trace this dataset event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different dataset events together as part of a full trace. - * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on - * tracing + * A unique identifier used to link different dataset events together as part of a + * full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** Whether this span is a root span */ - @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot + @JsonProperty("is_root") + @ExcludeMissing + fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -177,24 +189,25 @@ private constructor( private var validated: Boolean = false - fun validate(): DatasetEvent = apply { - if (validated) { - return@apply - } + fun validate(): DatasetEvent = + apply { + if (validated) { + return@apply + } - id() - _xactId() - created() - datasetId() - projectId() - rootSpanId() - spanId() - isRoot() - metadata().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - tags() - validated = true - } + id() + _xactId() + created() + datasetId() + projectId() + rootSpanId() + spanId() + isRoot() + metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -204,6 +217,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetEvent]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -214,7 +228,8 @@ private constructor( * .spanId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetEvent]. */ @@ -236,97 +251,130 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetEvent: DatasetEvent) = apply { - id = datasetEvent.id - _xactId = datasetEvent._xactId - created = datasetEvent.created - datasetId = datasetEvent.datasetId - projectId = datasetEvent.projectId - rootSpanId = datasetEvent.rootSpanId - spanId = datasetEvent.spanId - expected = datasetEvent.expected - input = datasetEvent.input - isRoot = datasetEvent.isRoot - metadata = datasetEvent.metadata - origin = datasetEvent.origin - tags = datasetEvent.tags.map { it.toMutableList() } - additionalProperties = datasetEvent.additionalProperties.toMutableMap() - } + internal fun from(datasetEvent: DatasetEvent) = + apply { + id = datasetEvent.id + _xactId = datasetEvent._xactId + created = datasetEvent.created + datasetId = datasetEvent.datasetId + projectId = datasetEvent.projectId + rootSpanId = datasetEvent.rootSpanId + spanId = datasetEvent.spanId + expected = datasetEvent.expected + input = datasetEvent.input + isRoot = datasetEvent.isRoot + metadata = datasetEvent.metadata + origin = datasetEvent.origin + tags = datasetEvent.tags.map { it.toMutableList() } + additionalProperties = datasetEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the dataset (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the dataset (see the `version` + * parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the dataset (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the dataset (see the `version` + * parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the dataset event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Unique identifier for the dataset */ fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) /** Unique identifier for the dataset */ - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** A unique identifier for the trace this dataset event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** A unique identifier for the trace this dataset event belongs to */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different dataset events together as part of a + * full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different dataset events together as part of a + * full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + * The argument that uniquely define an input case (an arbitrary, JSON serializable + * object) */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) @@ -338,34 +386,40 @@ private constructor( fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ - fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + fun isRoot(isRoot: JsonField) = + apply { + this.isRoot = isRoot + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Indicates the event was copied from another object. */ fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) @@ -374,7 +428,10 @@ private constructor( fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -383,66 +440,89 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): DatasetEvent = DatasetEvent( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("created", created), - checkRequired("datasetId", datasetId), - checkRequired("projectId", projectId), - checkRequired("rootSpanId", rootSpanId), - checkRequired("spanId", spanId), - expected, - input, - isRoot, - metadata, - origin, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "created", created + ), + checkRequired( + "datasetId", datasetId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "rootSpanId", rootSpanId + ), + checkRequired( + "spanId", spanId + ), + expected, + input, + isRoot, + metadata, + origin, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -451,20 +531,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -473,38 +555,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -518,21 +608,13 @@ private constructor( /** Indicates the event was copied from another object. */ @NoAutoDetect - class Origin - @JsonCreator - private constructor( + class Origin @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** ID of the original event. */ @@ -548,13 +630,19 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** Type of the object the event is originating from. */ @JsonProperty("object_type") @@ -567,17 +655,18 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - id() - _xactId() - objectId() - objectType() - validated = true - } + id() + _xactId() + objectId() + objectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -587,6 +676,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -594,7 +684,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -607,82 +698,111 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() + } /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalProperties.toImmutable(), ) } /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -715,9 +835,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -738,8 +860,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -759,7 +881,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -778,20 +900,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -800,11 +919,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -813,16 +932,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetEvent && id == other.id && _xactId == other._xactId && created == other.created && datasetId == other.datasetId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && origin == other.origin && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetEvent && id == other.id && _xactId == other._xactId && created == other.created && datasetId == other.datasetId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && origin == other.origin && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -831,6 +949,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, datasetId=$datasetId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, origin=$origin, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, datasetId=$datasetId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, origin=$origin, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 1b7d0197..fe58a5b8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Log feedback for a set of dataset events */ -class DatasetFeedbackParams -private constructor( +class DatasetFeedbackParams private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("feedback") - @ExcludeMissing - private val feedback: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of dataset feedback items */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - feedback().forEach { it.validate() } - validated = true - } + feedback().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - feedback = body.feedback.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of dataset feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) /** A list of dataset feedback items */ - fun feedback(feedback: JsonField>) = apply { - this.feedback = feedback.map { it.toMutableList() } - } + fun feedback(feedback: JsonField>) = + apply { + this.feedback = feedback.map { it.toMutableList() } + } /** A list of dataset feedback items */ - fun addFeedback(feedback: FeedbackDatasetItem) = apply { - this.feedback = - (this.feedback ?: JsonField.of(mutableListOf())).also { + fun addFeedback(feedback: FeedbackDatasetItem) = + apply { + this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { checkKnown("feedback", it).add(feedback) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("feedback", feedback).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "feedback", feedback + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -174,8 +184,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -183,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DatasetFeedbackParams]. + * Returns a mutable builder for constructing an instance of + * [DatasetFeedbackParams]. * * The following fields are required: + * * ```java * .datasetId() * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetFeedbackParams]. */ @@ -204,163 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetFeedbackParams: DatasetFeedbackParams) = apply { - datasetId = datasetFeedbackParams.datasetId - body = datasetFeedbackParams.body.toBuilder() - additionalHeaders = datasetFeedbackParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetFeedbackParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetFeedbackParams: DatasetFeedbackParams) = + apply { + datasetId = datasetFeedbackParams.datasetId + body = datasetFeedbackParams.body.toBuilder() + additionalHeaders = datasetFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFeedbackParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** A list of dataset feedback items */ - fun feedback(feedback: List) = apply { body.feedback(feedback) } + fun feedback(feedback: List) = + apply { + body.feedback(feedback) + } /** A list of dataset feedback items */ - fun feedback(feedback: JsonField>) = apply { - body.feedback(feedback) - } + fun feedback(feedback: JsonField>) = + apply { + body.feedback(feedback) + } /** A list of dataset feedback items */ - fun addFeedback(feedback: FeedbackDatasetItem) = apply { body.addFeedback(feedback) } + fun addFeedback(feedback: FeedbackDatasetItem) = + apply { + body.addFeedback(feedback) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetFeedbackParams = DatasetFeedbackParams( - checkRequired("datasetId", datasetId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetFeedbackParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetFeedbackParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index e045595c..a1612e8b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -12,12 +12,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but + * with the parameters in the URL query rather than in the request body. For more + * complex queries, use the `POST /btql` endpoint. */ -class DatasetFetchParams -private constructor( +class DatasetFetchParams private constructor( private val datasetId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -25,6 +24,7 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -33,52 +33,55 @@ private constructor( /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version) @@ -89,20 +92,36 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.maxRootSpanId?.let { + queryParams.put( + "max_root_span_id", listOf(it.toString()) + ) + } + this.maxXactId?.let { + queryParams.put( + "max_xact_id", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -113,11 +132,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetFetchParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetFetchParams]. */ @@ -133,263 +154,310 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetFetchParams: DatasetFetchParams) = apply { - datasetId = datasetFetchParams.datasetId - limit = datasetFetchParams.limit - maxRootSpanId = datasetFetchParams.maxRootSpanId - maxXactId = datasetFetchParams.maxXactId - version = datasetFetchParams.version - additionalHeaders = datasetFetchParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetFetchParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetFetchParams: DatasetFetchParams) = + apply { + datasetId = datasetFetchParams.datasetId + limit = datasetFetchParams.limit + maxRootSpanId = datasetFetchParams.maxRootSpanId + maxXactId = datasetFetchParams.maxXactId + version = datasetFetchParams.version + additionalHeaders = datasetFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFetchParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String?) = + apply { + this.maxXactId = maxXactId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetFetchParams = DatasetFetchParams( - checkRequired("datasetId", datasetId), - limit, - maxRootSpanId, - maxXactId, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + limit, + maxRootSpanId, + maxXactId, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetFetchParams && datasetId == other.datasetId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFetchParams && datasetId == other.datasetId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 02ffad07..d0c8d415 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -22,138 +22,146 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but + * with the parameters in the request body rather than in the URL query. For more + * complex queries, use the `POST /btql` endpoint. */ -class DatasetFetchPostParams -private constructor( +class DatasetFetchPostParams private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ fun datasetId(): String = datasetId /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = body.cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = body.limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = body.maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = body.maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun _cursor(): JsonField = body._cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxXactId(): JsonField = body._maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun _version(): JsonField = body._version() @@ -163,169 +171,168 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), - @JsonProperty("limit") - @ExcludeMissing - private val limit: JsonField = JsonMissing.of(), - @JsonProperty("max_root_span_id") - @ExcludeMissing - private val maxRootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("max_xact_id") - @ExcludeMissing - private val maxXactId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") @ExcludeMissing private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") @ExcludeMissing private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(): Optional = - Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(): Optional = - Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + @JsonProperty("limit") + @ExcludeMissing + fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId + @JsonProperty("max_xact_id") + @ExcludeMissing + fun _maxXactId(): JsonField = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -333,25 +340,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true } - cursor() - limit() - maxRootSpanId() - maxXactId() - version() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -365,261 +374,284 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - cursor = body.cursor - limit = body.limit - maxRootSpanId = body.maxRootSpanId - maxXactId = body.maxXactId - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { this.limit = limit } + fun limit(limit: JsonField) = + apply { + this.limit = limit + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: JsonField) = + apply { + this.maxXactId = maxXactId + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: String?) = version(JsonField.ofNullable(version)) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun version(version: JsonField) = + apply { + this.version = version + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toImmutable(), + cursor, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -628,8 +660,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -637,14 +668,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DatasetFetchPostParams]. + * Returns a mutable builder for constructing an instance of + * [DatasetFetchPostParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetFetchPostParams]. */ @@ -657,358 +691,431 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = apply { - datasetId = datasetFetchPostParams.datasetId - body = datasetFetchPostParams.body.toBuilder() - additionalHeaders = datasetFetchPostParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetFetchPostParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = + apply { + datasetId = datasetFetchPostParams.datasetId + body = datasetFetchPostParams.body.toBuilder() + additionalHeaders = datasetFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFetchPostParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: String?) = apply { body.cursor(cursor) } + fun cursor(cursor: String?) = + apply { + body.cursor(cursor) + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } + fun cursor(cursor: JsonField) = + apply { + body.cursor(cursor) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { body.limit(limit) } + fun limit(limit: Long?) = + apply { + body.limit(limit) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { body.limit(limit) } + fun limit(limit: JsonField) = + apply { + body.limit(limit) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: String?) = + apply { + body.maxXactId(maxXactId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: JsonField) = + apply { + body.maxXactId(maxXactId) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { body.version(version) } + fun version(version: String?) = + apply { + body.version(version) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { body.version(version) } + fun version(version: JsonField) = + apply { + body.version(version) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetFetchPostParams = DatasetFetchPostParams( - checkRequired("datasetId", datasetId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetFetchPostParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetFetchPostParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 043cce99..dc6fca8e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Insert a set of events into the dataset */ -class DatasetInsertParams -private constructor( +class DatasetInsertParams private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of dataset events to insert */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - validated = true - } + events().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - events = body.events.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of dataset events to insert */ fun events(events: List) = events(JsonField.of(events)) /** A list of dataset events to insert */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of dataset events to insert */ - fun addEvent(event: InsertDatasetEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: InsertDatasetEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("events", events).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -185,12 +195,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetInsertParams]. * * The following fields are required: + * * ```java * .datasetId() * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetInsertParams]. */ @@ -203,161 +215,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetInsertParams: DatasetInsertParams) = apply { - datasetId = datasetInsertParams.datasetId - body = datasetInsertParams.body.toBuilder() - additionalHeaders = datasetInsertParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetInsertParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetInsertParams: DatasetInsertParams) = + apply { + datasetId = datasetInsertParams.datasetId + body = datasetInsertParams.body.toBuilder() + additionalHeaders = datasetInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetInsertParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** A list of dataset events to insert */ - fun events(events: List) = apply { body.events(events) } + fun events(events: List) = + apply { + body.events(events) + } /** A list of dataset events to insert */ - fun events(events: JsonField>) = apply { body.events(events) } + fun events(events: JsonField>) = + apply { + body.events(events) + } /** A list of dataset events to insert */ - fun addEvent(event: InsertDatasetEvent) = apply { body.addEvent(event) } + fun addEvent(event: InsertDatasetEvent) = + apply { + body.addEvent(event) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetInsertParams = DatasetInsertParams( - checkRequired("datasetId", datasetId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetInsertParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetInsertParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index ae489e32..6218008e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.DatasetService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all datasets. The datasets are sorted by creation date, with the most recently-created - * datasets coming first + * List out all datasets. The datasets are sorted by creation date, with the most + * recently-created datasets coming first */ -class DatasetListPage -private constructor( +class DatasetListPage private constructor( private val datasetsService: DatasetService, private val params: DatasetListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetListPage && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is DatasetListPage && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ - override fun toString() = - "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" + override fun toString() = "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - DatasetListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - DatasetListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { datasetsService.list(it) } + return getNextPageParams().map { datasetsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -84,16 +74,18 @@ private constructor( @JvmStatic fun of(datasetsService: DatasetService, params: DatasetListParams, response: Response) = - DatasetListPage(datasetsService, params, response) + DatasetListPage( + datasetsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -107,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [DatasetListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -143,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: DatasetListPage) : Iterable { + class AutoPager( + private val firstPage: DatasetListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index edf89d75..574330d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.DatasetServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all datasets. The datasets are sorted by creation date, with the most recently-created - * datasets coming first + * List out all datasets. The datasets are sorted by creation date, with the most + * recently-created datasets coming first */ -class DatasetListPageAsync -private constructor( +class DatasetListPageAsync private constructor( private val datasetsService: DatasetServiceAsync, private val params: DatasetListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetListPageAsync && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is DatasetListPageAsync && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ - override fun toString() = - "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" + override fun toString() = "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - DatasetListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - DatasetListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { datasetsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + datasetsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,20 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - datasetsService: DatasetServiceAsync, - params: DatasetListParams, - response: Response, - ) = DatasetListPageAsync(datasetsService, params, response) + fun of(datasetsService: DatasetServiceAsync, params: DatasetListParams, response: Response) = + DatasetListPageAsync( + datasetsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -112,34 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** Returns a mutable builder for constructing an instance of [DatasetListPageAsync]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [DatasetListPageAsync]. + */ + @JvmStatic + fun builder() = Builder() } class Builder { @@ -148,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: DatasetListPageAsync) { + class AutoPager( + private val firstPage: DatasetListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Dataset) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Dataset) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 5ae454e3..63b098eb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all datasets. The datasets are sorted by creation date, with the most recently-created - * datasets coming first + * List out all datasets. The datasets are sorted by creation date, with the most + * recently-created datasets coming first */ -class DatasetListParams -private constructor( +class DatasetListParams private constructor( private val datasetName: String?, private val endingBefore: String?, private val ids: Ids?, @@ -38,6 +37,7 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the dataset to search for */ @@ -46,15 +46,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -73,9 +73,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -86,27 +86,61 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.datasetName?.let { queryParams.put("dataset_name", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.datasetName?.let { + queryParams.put( + "dataset_name", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): DatasetListParams = builder().build() + @JvmStatic + fun none(): DatasetListParams = builder().build() /** Returns a mutable builder for constructing an instance of [DatasetListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetListParams]. */ @@ -125,21 +159,25 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetListParams: DatasetListParams) = apply { - datasetName = datasetListParams.datasetName - endingBefore = datasetListParams.endingBefore - ids = datasetListParams.ids - limit = datasetListParams.limit - orgName = datasetListParams.orgName - projectId = datasetListParams.projectId - projectName = datasetListParams.projectName - startingAfter = datasetListParams.startingAfter - additionalHeaders = datasetListParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetListParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetListParams: DatasetListParams) = + apply { + datasetName = datasetListParams.datasetName + endingBefore = datasetListParams.endingBefore + ids = datasetListParams.ids + limit = datasetListParams.limit + orgName = datasetListParams.orgName + projectId = datasetListParams.projectId + projectName = datasetListParams.projectName + startingAfter = datasetListParams.startingAfter + additionalHeaders = datasetListParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetListParams.additionalQueryParams.toBuilder() + } /** Name of the dataset to search for */ - fun datasetName(datasetName: String?) = apply { this.datasetName = datasetName } + fun datasetName(datasetName: String?) = + apply { + this.datasetName = datasetName + } /** Name of the dataset to search for */ fun datasetName(datasetName: Optional) = datasetName(datasetName.getOrNull()) @@ -147,47 +185,56 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -196,19 +243,28 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) @@ -216,146 +272,174 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetListParams = DatasetListParams( - datasetName, - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + datasetName, + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -373,19 +457,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -400,12 +484,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -415,60 +504,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetListParams && datasetName == other.datasetName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetListParams && datasetName == other.datasetName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index a75b190a..96f02be2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a dataset object by its id */ -class DatasetRetrieveParams -private constructor( +class DatasetRetrieveParams private constructor( private val datasetId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DatasetRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = apply { - datasetId = datasetRetrieveParams.datasetId - additionalHeaders = datasetRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = + apply { + datasetId = datasetRetrieveParams.datasetId + additionalHeaders = datasetRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetRetrieveParams = DatasetRetrieveParams( - checkRequired("datasetId", datasetId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetRetrieveParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetRetrieveParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index bea55242..b1a3a575 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -12,18 +12,21 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Summarize dataset */ -class DatasetSummarizeParams -private constructor( +class DatasetSummarizeParams private constructor( private val datasetId: String, private val summarizeData: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ fun datasetId(): String = datasetId - /** Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ + /** + * Whether to summarize the data. If false (or omitted), only the metadata will be + * returned. + */ fun summarizeData(): Optional = Optional.ofNullable(summarizeData) fun _additionalHeaders(): Headers = additionalHeaders @@ -33,17 +36,21 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.summarizeData?.let { queryParams.put("summarize_data", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.summarizeData?.let { + queryParams.put( + "summarize_data", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -51,14 +58,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DatasetSummarizeParams]. + * Returns a mutable builder for constructing an instance of + * [DatasetSummarizeParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetSummarizeParams]. */ @@ -71,149 +81,185 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetSummarizeParams: DatasetSummarizeParams) = apply { - datasetId = datasetSummarizeParams.datasetId - summarizeData = datasetSummarizeParams.summarizeData - additionalHeaders = datasetSummarizeParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetSummarizeParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetSummarizeParams: DatasetSummarizeParams) = + apply { + datasetId = datasetSummarizeParams.datasetId + summarizeData = datasetSummarizeParams.summarizeData + additionalHeaders = datasetSummarizeParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetSummarizeParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** - * Whether to summarize the data. If false (or omitted), only the metadata will be returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be + * returned. */ - fun summarizeData(summarizeData: Boolean?) = apply { this.summarizeData = summarizeData } + fun summarizeData(summarizeData: Boolean?) = + apply { + this.summarizeData = summarizeData + } /** - * Whether to summarize the data. If false (or omitted), only the metadata will be returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be + * returned. */ fun summarizeData(summarizeData: Boolean) = summarizeData(summarizeData as Boolean?) /** - * Whether to summarize the data. If false (or omitted), only the metadata will be returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be + * returned. */ - fun summarizeData(summarizeData: Optional) = - summarizeData(summarizeData.getOrNull()) + fun summarizeData(summarizeData: Optional) = summarizeData(summarizeData.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetSummarizeParams = DatasetSummarizeParams( - checkRequired("datasetId", datasetId), - summarizeData, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + summarizeData, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetSummarizeParams && datasetId == other.datasetId && summarizeData == other.summarizeData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetSummarizeParams && datasetId == other.datasetId && summarizeData == other.summarizeData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index a125d34b..dc748441 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a dataset object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class DatasetUpdateParams -private constructor( +class DatasetUpdateParams private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -61,39 +61,31 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Textual description of the dataset */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -107,10 +99,14 @@ private constructor( fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -118,23 +114,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + description() + metadata().ifPresent { it.validate() } + name() + validated = true } - description() - metadata().ifPresent { it.validate() } - name() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -146,12 +144,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - description = body.description - metadata = body.metadata - name = body.name - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + description = body.description + metadata = body.metadata + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -160,9 +159,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -171,7 +171,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -180,37 +183,52 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun name(name: JsonField) = + apply { + this.name = name + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(description, metadata, name, additionalProperties.toImmutable()) + Body( + description, + metadata, + name, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && description == other.description && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -219,8 +237,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Body{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -231,11 +248,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetUpdateParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetUpdateParams]. */ @@ -248,176 +267,232 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetUpdateParams: DatasetUpdateParams) = apply { - datasetId = datasetUpdateParams.datasetId - body = datasetUpdateParams.body.toBuilder() - additionalHeaders = datasetUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetUpdateParams: DatasetUpdateParams) = + apply { + datasetId = datasetUpdateParams.datasetId + body = datasetUpdateParams.body.toBuilder() + additionalHeaders = datasetUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetUpdateParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** Textual description of the dataset */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the dataset */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetUpdateParams = DatasetUpdateParams( - checkRequired("datasetId", datasetId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the dataset */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -426,20 +501,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -448,38 +525,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -492,15 +577,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 10a99c22..7cf44815 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -22,24 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class EnvVar -@JsonCreator -private constructor( +class EnvVar @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("used") - @ExcludeMissing - private val used: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("used") @ExcludeMissing private val used: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the environment variable */ @@ -61,13 +52,19 @@ private constructor( fun used(): Optional = Optional.ofNullable(used.getNullable("used")) /** Unique identifier for the environment variable */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** The name of the environment variable */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ @JsonProperty("object_type") @@ -75,10 +72,14 @@ private constructor( fun _objectType(): JsonField = objectType /** Date of environment variable creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date the environment variable was last used */ - @JsonProperty("used") @ExcludeMissing fun _used(): JsonField = used + @JsonProperty("used") + @ExcludeMissing + fun _used(): JsonField = used @JsonAnyGetter @ExcludeMissing @@ -86,19 +87,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EnvVar = apply { - if (validated) { - return@apply - } + fun validate(): EnvVar = + apply { + if (validated) { + return@apply + } - id() - name() - objectId() - objectType() - created() - used() - validated = true - } + id() + name() + objectId() + objectType() + created() + used() + validated = true + } fun toBuilder() = Builder().from(this) @@ -108,6 +110,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVar]. * * The following fields are required: + * * ```java * .id() * .name() @@ -115,7 +118,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVar]. */ @@ -130,39 +134,52 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVar: EnvVar) = apply { - id = envVar.id - name = envVar.name - objectId = envVar.objectId - objectType = envVar.objectType - created = envVar.created - used = envVar.used - additionalProperties = envVar.additionalProperties.toMutableMap() - } + internal fun from(envVar: EnvVar) = + apply { + id = envVar.id + name = envVar.name + objectId = envVar.objectId + objectType = envVar.objectType + created = envVar.created + used = envVar.used + additionalProperties = envVar.additionalProperties.toMutableMap() + } /** Unique identifier for the environment variable */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the environment variable */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** Date of environment variable creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -171,7 +188,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of environment variable creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date the environment variable was last used */ fun used(used: OffsetDateTime?) = used(JsonField.ofNullable(used)) @@ -180,51 +200,73 @@ private constructor( fun used(used: Optional) = used(used.getOrNull()) /** Date the environment variable was last used */ - fun used(used: JsonField) = apply { this.used = used } + fun used(used: JsonField) = + apply { + this.used = used + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): EnvVar = EnvVar( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - created, - used, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + created, + used, + additionalProperties.toImmutable(), ) } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -248,9 +290,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -258,17 +302,18 @@ private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -281,11 +326,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -298,23 +343,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -323,11 +365,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVar && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && created == other.created && used == other.used && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVar && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && created == other.created && used == other.used && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -336,6 +378,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "EnvVar{id=$id, name=$name, objectId=$objectId, objectType=$objectType, created=$created, used=$used, additionalProperties=$additionalProperties}" + override fun toString() = "EnvVar{id=$id, name=$name, objectId=$objectId, objectType=$objectType, created=$created, used=$used, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index b088aebe..2861902e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -24,14 +24,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new env_var. If there is an existing env_var with the same name as the one specified in - * the request, will return the existing env_var unmodified + * Create a new env_var. If there is an existing env_var with the same name as the + * one specified in the request, will return the existing env_var unmodified */ -class EnvVarCreateParams -private constructor( +class EnvVarCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The name of the environment variable */ @@ -64,30 +64,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the environment variable */ @@ -103,10 +94,14 @@ private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** The name of the environment variable */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ @JsonProperty("object_type") @@ -114,7 +109,9 @@ private constructor( fun _objectType(): JsonField = objectType /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -122,18 +119,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + value() + validated = true } - name() - objectId() - objectType() - value() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -142,13 +140,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -161,33 +161,41 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - value = body.value - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) @@ -196,43 +204,59 @@ private constructor( fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = + apply { + this.value = value + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - value, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + value, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -241,8 +265,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -253,13 +276,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarCreateParams]. * * The following fields are required: + * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarCreateParams]. */ @@ -271,176 +296,239 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarCreateParams: EnvVarCreateParams) = apply { - body = envVarCreateParams.body.toBuilder() - additionalHeaders = envVarCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarCreateParams: EnvVarCreateParams) = + apply { + body = envVarCreateParams.body.toBuilder() + additionalHeaders = envVarCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarCreateParams.additionalQueryParams.toBuilder() + } /** The name of the environment variable */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** The name of the environment variable */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String?) = apply { body.value(value) } + fun value(value: String?) = + apply { + body.value(value) + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { body.value(value) } + fun value(value: JsonField) = + apply { + body.value(value) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarCreateParams = EnvVarCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -464,9 +552,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -474,17 +564,18 @@ private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -497,11 +588,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -514,23 +605,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -539,15 +627,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index d9d09741..2d714d22 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an env_var object by its id */ -class EnvVarDeleteParams -private constructor( +class EnvVarDeleteParams private constructor( private val envVarId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** EnvVar id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> envVarId - else -> "" - } + return when (index) { + 0 -> envVarId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarDeleteParams]. * * The following fields are required: + * * ```java * .envVarId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVarDeleteParams: EnvVarDeleteParams) = apply { - envVarId = envVarDeleteParams.envVarId - additionalHeaders = envVarDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = envVarDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(envVarDeleteParams: EnvVarDeleteParams) = + apply { + envVarId = envVarDeleteParams.envVarId + additionalHeaders = envVarDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = envVarDeleteParams.additionalBodyProperties.toMutableMap() + } /** EnvVar id */ - fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } + fun envVarId(envVarId: String) = + apply { + this.envVarId = envVarId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): EnvVarDeleteParams = EnvVarDeleteParams( - checkRequired("envVarId", envVarId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "envVarId", envVarId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarDeleteParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarDeleteParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListParams.kt index b0e9f3c4..53e139bb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListParams.kt @@ -26,11 +26,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all env_vars. The env_vars are sorted by creation date, with the most recently-created - * env_vars coming first + * List out all env_vars. The env_vars are sorted by creation date, with the most + * recently-created env_vars coming first */ -class EnvVarListParams -private constructor( +class EnvVarListParams private constructor( private val envVarName: String?, private val ids: Ids?, private val limit: Long?, @@ -38,14 +37,15 @@ private constructor( private val objectType: ObjectType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the env_var to search for */ fun envVarName(): Optional = Optional.ofNullable(envVarName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,24 +65,46 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.envVarName?.let { queryParams.put("env_var_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.objectId?.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType?.let { queryParams.put("object_type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.envVarName?.let { + queryParams.put( + "env_var_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.objectId?.let { + queryParams.put( + "object_id", listOf(it.toString()) + ) + } + this.objectType?.let { + queryParams.put( + "object_type", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): EnvVarListParams = builder().build() + @JvmStatic + fun none(): EnvVarListParams = builder().build() /** Returns a mutable builder for constructing an instance of [EnvVarListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarListParams]. */ @@ -98,48 +120,58 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarListParams: EnvVarListParams) = apply { - envVarName = envVarListParams.envVarName - ids = envVarListParams.ids - limit = envVarListParams.limit - objectId = envVarListParams.objectId - objectType = envVarListParams.objectType - additionalHeaders = envVarListParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarListParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarListParams: EnvVarListParams) = + apply { + envVarName = envVarListParams.envVarName + ids = envVarListParams.ids + limit = envVarListParams.limit + objectId = envVarListParams.objectId + objectType = envVarListParams.objectType + additionalHeaders = envVarListParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarListParams.additionalQueryParams.toBuilder() + } /** Name of the env_var to search for */ - fun envVarName(envVarName: String?) = apply { this.envVarName = envVarName } + fun envVarName(envVarName: String?) = + apply { + this.envVarName = envVarName + } /** Name of the env_var to search for */ fun envVarName(envVarName: Optional) = envVarName(envVarName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -148,138 +180,170 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String?) = apply { this.objectId = objectId } + fun objectId(objectId: String?) = + apply { + this.objectId = objectId + } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: Optional) = objectId(objectId.getOrNull()) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType?) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType?) = + apply { + this.objectType = objectType + } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: Optional) = objectType(objectType.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarListParams = EnvVarListParams( - envVarName, - ids, - limit, - objectId, - objectType, - additionalHeaders.build(), - additionalQueryParams.build(), + envVarName, + ids, + limit, + objectId, + objectType, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -297,19 +361,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -324,12 +388,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -339,62 +408,63 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -418,9 +488,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -428,17 +500,18 @@ private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -451,11 +524,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -468,23 +541,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -493,15 +563,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarListParams && envVarName == other.envVarName && ids == other.ids && limit == other.limit && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarListParams && envVarName == other.envVarName && ids == other.ids && limit == other.limit && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 014c0040..405f6428 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -18,20 +18,19 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class EnvVarListResponse -@JsonCreator -private constructor( - @JsonProperty("objects") - @ExcludeMissing - private val objects: JsonField> = JsonMissing.of(), +class EnvVarListResponse @JsonCreator private constructor( + @JsonProperty("objects") @ExcludeMissing private val objects: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of env_var objects */ fun objects(): List = objects.getRequired("objects") /** A list of env_var objects */ - @JsonProperty("objects") @ExcludeMissing fun _objects(): JsonField> = objects + @JsonProperty("objects") + @ExcludeMissing + fun _objects(): JsonField> = objects @JsonAnyGetter @ExcludeMissing @@ -39,14 +38,15 @@ private constructor( private var validated: Boolean = false - fun validate(): EnvVarListResponse = apply { - if (validated) { - return@apply - } + fun validate(): EnvVarListResponse = + apply { + if (validated) { + return@apply + } - objects().forEach { it.validate() } - validated = true - } + objects().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -56,11 +56,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarListResponse]. * * The following fields are required: + * * ```java * .objects() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarListResponse]. */ @@ -70,59 +72,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVarListResponse: EnvVarListResponse) = apply { - objects = envVarListResponse.objects.map { it.toMutableList() } - additionalProperties = envVarListResponse.additionalProperties.toMutableMap() - } + internal fun from(envVarListResponse: EnvVarListResponse) = + apply { + objects = envVarListResponse.objects.map { it.toMutableList() } + additionalProperties = envVarListResponse.additionalProperties.toMutableMap() + } /** A list of env_var objects */ fun objects(objects: List) = objects(JsonField.of(objects)) /** A list of env_var objects */ - fun objects(objects: JsonField>) = apply { - this.objects = objects.map { it.toMutableList() } - } + fun objects(objects: JsonField>) = + apply { + this.objects = objects.map { it.toMutableList() } + } /** A list of env_var objects */ - fun addObject(object_: EnvVar) = apply { - objects = - (objects ?: JsonField.of(mutableListOf())).also { + fun addObject(object_: EnvVar) = + apply { + objects = (objects ?: JsonField.of(mutableListOf())).also { checkKnown("objects", it).add(object_) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): EnvVarListResponse = EnvVarListResponse( - checkRequired("objects", objects).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "objects", objects + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarListResponse && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarListResponse && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -131,6 +143,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "EnvVarListResponse{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "EnvVarListResponse{objects=$objects, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index da9d9b85..38c2e079 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -24,14 +24,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace env_var. If there is an existing env_var with the same name as the one - * specified in the request, will replace the existing env_var with the provided fields + * Create or replace env_var. If there is an existing env_var with the same name as + * the one specified in the request, will replace the existing env_var with the + * provided fields */ -class EnvVarReplaceParams -private constructor( +class EnvVarReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The name of the environment variable */ @@ -64,30 +65,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the environment variable */ @@ -103,10 +95,14 @@ private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** The name of the environment variable */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ @JsonProperty("object_type") @@ -114,7 +110,9 @@ private constructor( fun _objectType(): JsonField = objectType /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -122,18 +120,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + value() + validated = true } - name() - objectId() - objectType() - value() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -142,13 +141,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -161,33 +162,41 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - value = body.value - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) @@ -196,43 +205,59 @@ private constructor( fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = + apply { + this.value = value + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - value, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + value, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -241,8 +266,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -253,13 +277,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarReplaceParams]. * * The following fields are required: + * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarReplaceParams]. */ @@ -271,176 +297,239 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarReplaceParams: EnvVarReplaceParams) = apply { - body = envVarReplaceParams.body.toBuilder() - additionalHeaders = envVarReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarReplaceParams: EnvVarReplaceParams) = + apply { + body = envVarReplaceParams.body.toBuilder() + additionalHeaders = envVarReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarReplaceParams.additionalQueryParams.toBuilder() + } /** The name of the environment variable */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** The name of the environment variable */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String?) = apply { body.value(value) } + fun value(value: String?) = + apply { + body.value(value) + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { body.value(value) } + fun value(value: JsonField) = + apply { + body.value(value) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarReplaceParams = EnvVarReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -464,9 +553,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -474,17 +565,18 @@ private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -497,11 +589,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -514,23 +606,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -539,15 +628,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 0e424916..ef2d0266 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an env_var object by its id */ -class EnvVarRetrieveParams -private constructor( +class EnvVarRetrieveParams private constructor( private val envVarId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** EnvVar id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> envVarId - else -> "" - } + return when (index) { + 0 -> envVarId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EnvVarRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [EnvVarRetrieveParams]. * * The following fields are required: + * * ```java * .envVarId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarRetrieveParams: EnvVarRetrieveParams) = apply { - envVarId = envVarRetrieveParams.envVarId - additionalHeaders = envVarRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarRetrieveParams: EnvVarRetrieveParams) = + apply { + envVarId = envVarRetrieveParams.envVarId + additionalHeaders = envVarRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarRetrieveParams.additionalQueryParams.toBuilder() + } /** EnvVar id */ - fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } + fun envVarId(envVarId: String) = + apply { + this.envVarId = envVarId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarRetrieveParams = EnvVarRetrieveParams( - checkRequired("envVarId", envVarId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "envVarId", envVarId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarRetrieveParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarRetrieveParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 11d4bded..a937e768 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an env_var object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update an env_var object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class EnvVarUpdateParams -private constructor( +class EnvVarUpdateParams private constructor( private val envVarId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** EnvVar id */ @@ -55,31 +55,26 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> envVarId - else -> "" - } + return when (index) { + 0 -> envVarId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the environment variable */ @@ -89,10 +84,14 @@ private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** The name of the environment variable */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -100,15 +99,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - value() - validated = true - } + name() + value() + validated = true + } fun toBuilder() = Builder().from(this) @@ -118,11 +118,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -133,17 +135,21 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - value = body.value - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) @@ -152,37 +158,53 @@ private constructor( fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = + apply { + this.value = value + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(checkRequired("name", name), value, additionalProperties.toImmutable()) + Body( + checkRequired( + "name", name + ), + value, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -191,8 +213,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -203,12 +224,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarUpdateParams]. * * The following fields are required: + * * ```java * .envVarId() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarUpdateParams]. */ @@ -221,167 +244,218 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarUpdateParams: EnvVarUpdateParams) = apply { - envVarId = envVarUpdateParams.envVarId - body = envVarUpdateParams.body.toBuilder() - additionalHeaders = envVarUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarUpdateParams: EnvVarUpdateParams) = + apply { + envVarId = envVarUpdateParams.envVarId + body = envVarUpdateParams.body.toBuilder() + additionalHeaders = envVarUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarUpdateParams.additionalQueryParams.toBuilder() + } /** EnvVar id */ - fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } + fun envVarId(envVarId: String) = + apply { + this.envVarId = envVarId + } /** The name of the environment variable */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** The name of the environment variable */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String?) = apply { body.value(value) } + fun value(value: String?) = + apply { + body.value(value) + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { body.value(value) } + fun value(value: JsonField) = + apply { + body.value(value) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarUpdateParams = EnvVarUpdateParams( - checkRequired("envVarId", envVarId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "envVarId", envVarId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarUpdateParams{envVarId=$envVarId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarUpdateParams{envVarId=$envVarId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 84bb86ae..63803002 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -35,17 +35,18 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into the - * Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and scoring - * functions. The API will then run the evaluation, create an experiment, and return the results - * along with a link to the experiment. To learn more about evals, see the + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is + * built into the Braintrust SDK. In the Eval API, you provide pointers to a + * dataset, task function, and scoring functions. The API will then run the + * evaluation, create an experiment, and return the results along with a link to + * the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ -class EvalCreateParams -private constructor( +class EvalCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The dataset to use */ @@ -61,26 +62,26 @@ private constructor( fun task(): Task = body.task() /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ fun baseExperimentId(): Optional = body.baseExperimentId() /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ fun baseExperimentName(): Optional = body.baseExperimentName() /** - * An optional name for the experiment created by this eval. If it conflicts with an existing - * experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ fun experimentName(): Optional = body.experimentName() /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ fun gitMetadataSettings(): Optional = body.gitMetadataSettings() @@ -88,14 +89,14 @@ private constructor( fun isPublic(): Optional = body.isPublic() /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in - * which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ fun maxConcurrency(): Optional = body.maxConcurrency() /** - * Optional experiment-level metadata to store about the evaluation. You can later use this to - * slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ fun metadata(): Optional = body.metadata() @@ -103,22 +104,22 @@ private constructor( fun repoInfo(): Optional = body.repoInfo() /** - * Whether to stream the results of the eval. If true, the request will return two events: one - * to indicate the experiment has started, and another upon completion. If false, the request - * will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ fun stream(): Optional = body.stream() /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which - * case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(): Optional = body.timeout() /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(): Optional = body.trialCount() @@ -135,26 +136,26 @@ private constructor( fun _task(): JsonField = body._task() /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ fun _baseExperimentId(): JsonField = body._baseExperimentId() /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ fun _baseExperimentName(): JsonField = body._baseExperimentName() /** - * An optional name for the experiment created by this eval. If it conflicts with an existing - * experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ fun _experimentName(): JsonField = body._experimentName() /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ fun _gitMetadataSettings(): JsonField = body._gitMetadataSettings() @@ -162,14 +163,14 @@ private constructor( fun _isPublic(): JsonField = body._isPublic() /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in - * which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ fun _maxConcurrency(): JsonField = body._maxConcurrency() /** - * Optional experiment-level metadata to store about the evaluation. You can later use this to - * slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ fun _metadata(): JsonField = body._metadata() @@ -177,22 +178,22 @@ private constructor( fun _repoInfo(): JsonField = body._repoInfo() /** - * Whether to stream the results of the eval. If true, the request will return two events: one - * to indicate the experiment has started, and another upon completion. If false, the request - * will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ fun _stream(): JsonField = body._stream() /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which - * case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun _timeout(): JsonField = body._timeout() /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun _trialCount(): JsonField = body._trialCount() @@ -202,59 +203,32 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( + class Body @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField> = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField> = JsonMissing.of(), @JsonProperty("task") @ExcludeMissing private val task: JsonField = JsonMissing.of(), - @JsonProperty("base_experiment_id") - @ExcludeMissing - private val baseExperimentId: JsonField = JsonMissing.of(), - @JsonProperty("base_experiment_name") - @ExcludeMissing - private val baseExperimentName: JsonField = JsonMissing.of(), - @JsonProperty("experiment_name") - @ExcludeMissing - private val experimentName: JsonField = JsonMissing.of(), - @JsonProperty("git_metadata_settings") - @ExcludeMissing - private val gitMetadataSettings: JsonField = JsonMissing.of(), - @JsonProperty("is_public") - @ExcludeMissing - private val isPublic: JsonField = JsonMissing.of(), - @JsonProperty("max_concurrency") - @ExcludeMissing - private val maxConcurrency: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") - @ExcludeMissing - private val repoInfo: JsonField = JsonMissing.of(), - @JsonProperty("stream") - @ExcludeMissing - private val stream: JsonField = JsonMissing.of(), - @JsonProperty("timeout") - @ExcludeMissing - private val timeout: JsonField = JsonMissing.of(), - @JsonProperty("trial_count") - @ExcludeMissing - private val trialCount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("base_experiment_id") @ExcludeMissing private val baseExperimentId: JsonField = JsonMissing.of(), + @JsonProperty("base_experiment_name") @ExcludeMissing private val baseExperimentName: JsonField = JsonMissing.of(), + @JsonProperty("experiment_name") @ExcludeMissing private val experimentName: JsonField = JsonMissing.of(), + @JsonProperty("git_metadata_settings") @ExcludeMissing private val gitMetadataSettings: JsonField = JsonMissing.of(), + @JsonProperty("is_public") @ExcludeMissing private val isPublic: JsonField = JsonMissing.of(), + @JsonProperty("max_concurrency") @ExcludeMissing private val maxConcurrency: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), + @JsonProperty("stream") @ExcludeMissing private val stream: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing private val timeout: JsonField = JsonMissing.of(), + @JsonProperty("trial_count") @ExcludeMissing private val trialCount: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The dataset to use */ @@ -270,46 +244,41 @@ private constructor( fun task(): Task = task.getRequired("task") /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(): Optional = - Optional.ofNullable(baseExperimentId.getNullable("base_experiment_id")) + fun baseExperimentId(): Optional = Optional.ofNullable(baseExperimentId.getNullable("base_experiment_id")) /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(): Optional = - Optional.ofNullable(baseExperimentName.getNullable("base_experiment_name")) + fun baseExperimentName(): Optional = Optional.ofNullable(baseExperimentName.getNullable("base_experiment_name")) /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(): Optional = - Optional.ofNullable(experimentName.getNullable("experiment_name")) + fun experimentName(): Optional = Optional.ofNullable(experimentName.getNullable("experiment_name")) /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(): Optional = - Optional.ofNullable(gitMetadataSettings.getNullable("git_metadata_settings")) + fun gitMetadataSettings(): Optional = Optional.ofNullable(gitMetadataSettings.getNullable("git_metadata_settings")) /** Whether the experiment should be public. Defaults to false. */ fun isPublic(): Optional = Optional.ofNullable(isPublic.getNullable("is_public")) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(): Optional = - Optional.ofNullable(maxConcurrency.getNullable("max_concurrency")) + fun maxConcurrency(): Optional = Optional.ofNullable(maxConcurrency.getNullable("max_concurrency")) /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -317,107 +286,124 @@ private constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(): Optional = Optional.ofNullable(timeout.getNullable("timeout")) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ - fun trialCount(): Optional = - Optional.ofNullable(trialCount.getNullable("trial_count")) + fun trialCount(): Optional = Optional.ofNullable(trialCount.getNullable("trial_count")) /** The dataset to use */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data /** Unique identifier for the project to run the eval in */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** The functions to score the eval on */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField> = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField> = scores /** The function to evaluate */ - @JsonProperty("task") @ExcludeMissing fun _task(): JsonField = task + @JsonProperty("task") + @ExcludeMissing + fun _task(): JsonField = task /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ @JsonProperty("base_experiment_id") @ExcludeMissing fun _baseExperimentId(): JsonField = baseExperimentId /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ @JsonProperty("base_experiment_name") @ExcludeMissing fun _baseExperimentName(): JsonField = baseExperimentName /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName(): JsonField = experimentName /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ @JsonProperty("git_metadata_settings") @ExcludeMissing fun _gitMetadataSettings(): JsonField = gitMetadataSettings /** Whether the experiment should be public. Defaults to false. */ - @JsonProperty("is_public") @ExcludeMissing fun _isPublic(): JsonField = isPublic + @JsonProperty("is_public") + @ExcludeMissing + fun _isPublic(): JsonField = isPublic /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ @JsonProperty("max_concurrency") @ExcludeMissing fun _maxConcurrency(): JsonField = maxConcurrency /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") + @ExcludeMissing + fun _repoInfo(): JsonField = repoInfo /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ - @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream + @JsonProperty("stream") + @ExcludeMissing + fun _stream(): JsonField = stream /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ - @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + @JsonProperty("timeout") + @ExcludeMissing + fun _timeout(): JsonField = timeout /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ @JsonProperty("trial_count") @ExcludeMissing @@ -429,28 +415,29 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } - - data().validate() - projectId() - scores().forEach { it.validate() } - task().validate() - baseExperimentId() - baseExperimentName() - experimentName() - gitMetadataSettings().ifPresent { it.validate() } - isPublic() - maxConcurrency() - metadata().ifPresent { it.validate() } - repoInfo().ifPresent { it.validate() } - stream() - timeout() - trialCount() - validated = true - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + data().validate() + projectId() + scores().forEach { it.validate() } + task().validate() + baseExperimentId() + baseExperimentName() + experimentName() + gitMetadataSettings().ifPresent { it.validate() } + isPublic() + maxConcurrency() + metadata().ifPresent { it.validate() } + repoInfo().ifPresent { it.validate() } + stream() + timeout() + trialCount() + validated = true + } fun toBuilder() = Builder().from(this) @@ -460,6 +447,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .data() * .projectId() @@ -467,7 +455,8 @@ private constructor( * .task() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -491,87 +480,93 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - data = body.data - projectId = body.projectId - scores = body.scores.map { it.toMutableList() } - task = body.task - baseExperimentId = body.baseExperimentId - baseExperimentName = body.baseExperimentName - experimentName = body.experimentName - gitMetadataSettings = body.gitMetadataSettings - isPublic = body.isPublic - maxConcurrency = body.maxConcurrency - metadata = body.metadata - repoInfo = body.repoInfo - stream = body.stream - timeout = body.timeout - trialCount = body.trialCount - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + data = body.data + projectId = body.projectId + scores = body.scores.map { it.toMutableList() } + task = body.task + baseExperimentId = body.baseExperimentId + baseExperimentName = body.baseExperimentName + experimentName = body.experimentName + gitMetadataSettings = body.gitMetadataSettings + isPublic = body.isPublic + maxConcurrency = body.maxConcurrency + metadata = body.metadata + repoInfo = body.repoInfo + stream = body.stream + timeout = body.timeout + trialCount = body.trialCount + additionalProperties = body.additionalProperties.toMutableMap() + } /** The dataset to use */ fun data(data: Data) = data(JsonField.of(data)) /** The dataset to use */ - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } /** Dataset id */ fun data(datasetId: Data.DatasetId) = data(Data.ofDatasetId(datasetId)) /** Project and dataset name */ - fun data(projectDatasetName: Data.ProjectDatasetName) = - data(Data.ofProjectDatasetName(projectDatasetName)) + fun data(projectDatasetName: Data.ProjectDatasetName) = data(Data.ofProjectDatasetName(projectDatasetName)) /** Unique identifier for the project to run the eval in */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** The functions to score the eval on */ fun scores(scores: List) = scores(JsonField.of(scores)) /** The functions to score the eval on */ - fun scores(scores: JsonField>) = apply { - this.scores = scores.map { it.toMutableList() } - } + fun scores(scores: JsonField>) = + apply { + this.scores = scores.map { it.toMutableList() } + } /** The functions to score the eval on */ - fun addScore(score: Score) = apply { - scores = - (scores ?: JsonField.of(mutableListOf())).also { + fun addScore(score: Score) = + apply { + scores = (scores ?: JsonField.of(mutableListOf())).also { checkKnown("scores", it).add(score) } - } + } /** Function id */ fun addScore(functionId: Score.FunctionId) = addScore(Score.ofFunctionId(functionId)) /** Project name and slug */ - fun addScore(projectSlug: Score.ProjectSlug) = - addScore(Score.ofProjectSlug(projectSlug)) + fun addScore(projectSlug: Score.ProjectSlug) = addScore(Score.ofProjectSlug(projectSlug)) /** Global function name */ - fun addScore(globalFunction: Score.GlobalFunction) = - addScore(Score.ofGlobalFunction(globalFunction)) + fun addScore(globalFunction: Score.GlobalFunction) = addScore(Score.ofGlobalFunction(globalFunction)) /** Prompt session id */ - fun addScore(promptSessionId: Score.PromptSessionId) = - addScore(Score.ofPromptSessionId(promptSessionId)) + fun addScore(promptSessionId: Score.PromptSessionId) = addScore(Score.ofPromptSessionId(promptSessionId)) /** Inline code function */ fun addScore(inlineCode: Score.InlineCode) = addScore(Score.ofInlineCode(inlineCode)) /** Inline prompt definition */ - fun addScore(inlinePrompt: Score.InlinePrompt) = - addScore(Score.ofInlinePrompt(inlinePrompt)) + fun addScore(inlinePrompt: Score.InlinePrompt) = addScore(Score.ofInlinePrompt(inlinePrompt)) /** The function to evaluate */ fun task(task: Task) = task(JsonField.of(task)) /** The function to evaluate */ - fun task(task: JsonField) = apply { this.task = task } + fun task(task: JsonField) = + apply { + this.task = task + } /** Function id */ fun task(functionId: Task.FunctionId) = task(Task.ofFunctionId(functionId)) @@ -580,12 +575,10 @@ private constructor( fun task(projectSlug: Task.ProjectSlug) = task(Task.ofProjectSlug(projectSlug)) /** Global function name */ - fun task(globalFunction: Task.GlobalFunction) = - task(Task.ofGlobalFunction(globalFunction)) + fun task(globalFunction: Task.GlobalFunction) = task(Task.ofGlobalFunction(globalFunction)) /** Prompt session id */ - fun task(promptSessionId: Task.PromptSessionId) = - task(Task.ofPromptSessionId(promptSessionId)) + fun task(promptSessionId: Task.PromptSessionId) = task(Task.ofPromptSessionId(promptSessionId)) /** Inline code function */ fun task(inlineCode: Task.InlineCode) = task(Task.ofInlineCode(inlineCode)) @@ -594,85 +587,82 @@ private constructor( fun task(inlinePrompt: Task.InlinePrompt) = task(Task.ofInlinePrompt(inlinePrompt)) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: String?) = - baseExperimentId(JsonField.ofNullable(baseExperimentId)) + fun baseExperimentId(baseExperimentId: String?) = baseExperimentId(JsonField.ofNullable(baseExperimentId)) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: Optional) = - baseExperimentId(baseExperimentId.getOrNull()) + fun baseExperimentId(baseExperimentId: Optional) = baseExperimentId(baseExperimentId.getOrNull()) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: JsonField) = apply { - this.baseExperimentId = baseExperimentId - } + fun baseExperimentId(baseExperimentId: JsonField) = + apply { + this.baseExperimentId = baseExperimentId + } /** - * An optional experiment name to use as a base. If specified, the new experiment will - * be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: String?) = - baseExperimentName(JsonField.ofNullable(baseExperimentName)) + fun baseExperimentName(baseExperimentName: String?) = baseExperimentName(JsonField.ofNullable(baseExperimentName)) /** - * An optional experiment name to use as a base. If specified, the new experiment will - * be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: Optional) = - baseExperimentName(baseExperimentName.getOrNull()) + fun baseExperimentName(baseExperimentName: Optional) = baseExperimentName(baseExperimentName.getOrNull()) /** - * An optional experiment name to use as a base. If specified, the new experiment will - * be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: JsonField) = apply { - this.baseExperimentName = baseExperimentName - } + fun baseExperimentName(baseExperimentName: JsonField) = + apply { + this.baseExperimentName = baseExperimentName + } /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: String) = - experimentName(JsonField.of(experimentName)) + fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: JsonField) = apply { - this.experimentName = experimentName - } + fun experimentName(experimentName: JsonField) = + apply { + this.experimentName = experimentName + } /** * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = - gitMetadataSettings(JsonField.ofNullable(gitMetadataSettings)) + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = gitMetadataSettings(JsonField.ofNullable(gitMetadataSettings)) /** * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: Optional) = - gitMetadataSettings(gitMetadataSettings.getOrNull()) + fun gitMetadataSettings(gitMetadataSettings: Optional) = gitMetadataSettings(gitMetadataSettings.getOrNull()) /** * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { - this.gitMetadataSettings = gitMetadataSettings - } + fun gitMetadataSettings(gitMetadataSettings: JsonField) = + apply { + this.gitMetadataSettings = gitMetadataSettings + } /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: Boolean?) = isPublic(JsonField.ofNullable(isPublic)) @@ -684,14 +674,16 @@ private constructor( fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: JsonField) = apply { this.isPublic = isPublic } + fun isPublic(isPublic: JsonField) = + apply { + this.isPublic = isPublic + } /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Double?) = - maxConcurrency(JsonField.ofNullable(maxConcurrency)) + fun maxConcurrency(maxConcurrency: Double?) = maxConcurrency(JsonField.ofNullable(maxConcurrency)) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to @@ -703,28 +695,31 @@ private constructor( * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Optional) = - maxConcurrency(maxConcurrency.getOrNull()) + fun maxConcurrency(maxConcurrency: Optional) = maxConcurrency(maxConcurrency.getOrNull()) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: JsonField) = apply { - this.maxConcurrency = maxConcurrency - } + fun maxConcurrency(maxConcurrency: JsonField) = + apply { + this.maxConcurrency = maxConcurrency + } /** - * Optional experiment-level metadata to store about the evaluation. You can later use - * this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * Optional experiment-level metadata to store about the evaluation. You can later use - * this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -733,120 +728,147 @@ private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: JsonField) = + apply { + this.repoInfo = repoInfo + } /** * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. If - * false, the request will return the evaluation's summary upon completion. + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ fun stream(stream: Boolean) = stream(JsonField.of(stream)) /** * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. If - * false, the request will return the evaluation's summary upon completion. + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ - fun stream(stream: JsonField) = apply { this.stream = stream } + fun stream(stream: JsonField) = + apply { + this.stream = stream + } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Double?) = timeout(JsonField.ofNullable(timeout)) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Double) = timeout(timeout as Double?) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ - fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + fun timeout(timeout: JsonField) = + apply { + this.timeout = timeout + } /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Double?) = trialCount(JsonField.ofNullable(trialCount)) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ - fun trialCount(trialCount: JsonField) = apply { this.trialCount = trialCount } + fun trialCount(trialCount: JsonField) = + apply { + this.trialCount = trialCount + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("data", data), - checkRequired("projectId", projectId), - checkRequired("scores", scores).map { it.toImmutable() }, - checkRequired("task", task), - baseExperimentId, - baseExperimentName, - experimentName, - gitMetadataSettings, - isPublic, - maxConcurrency, - metadata, - repoInfo, - stream, - timeout, - trialCount, - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "scores", scores + ).map { it.toImmutable() }, + checkRequired( + "task", task + ), + baseExperimentId, + baseExperimentName, + experimentName, + gitMetadataSettings, + isPublic, + maxConcurrency, + metadata, + repoInfo, + stream, + timeout, + trialCount, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -855,8 +877,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" + override fun toString() = "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -867,6 +888,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [EvalCreateParams]. * * The following fields are required: + * * ```java * .data() * .projectId() @@ -874,7 +896,8 @@ private constructor( * .task() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EvalCreateParams]. */ @@ -886,170 +909,246 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(evalCreateParams: EvalCreateParams) = apply { - body = evalCreateParams.body.toBuilder() - additionalHeaders = evalCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = evalCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(evalCreateParams: EvalCreateParams) = + apply { + body = evalCreateParams.body.toBuilder() + additionalHeaders = evalCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = evalCreateParams.additionalQueryParams.toBuilder() + } /** The dataset to use */ - fun data(data: Data) = apply { body.data(data) } + fun data(data: Data) = + apply { + body.data(data) + } /** The dataset to use */ - fun data(data: JsonField) = apply { body.data(data) } + fun data(data: JsonField) = + apply { + body.data(data) + } /** Dataset id */ - fun data(datasetId: Data.DatasetId) = apply { body.data(datasetId) } + fun data(datasetId: Data.DatasetId) = + apply { + body.data(datasetId) + } /** Project and dataset name */ - fun data(projectDatasetName: Data.ProjectDatasetName) = apply { - body.data(projectDatasetName) - } + fun data(projectDatasetName: Data.ProjectDatasetName) = + apply { + body.data(projectDatasetName) + } /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** The functions to score the eval on */ - fun scores(scores: List) = apply { body.scores(scores) } + fun scores(scores: List) = + apply { + body.scores(scores) + } /** The functions to score the eval on */ - fun scores(scores: JsonField>) = apply { body.scores(scores) } + fun scores(scores: JsonField>) = + apply { + body.scores(scores) + } /** The functions to score the eval on */ - fun addScore(score: Score) = apply { body.addScore(score) } + fun addScore(score: Score) = + apply { + body.addScore(score) + } /** Function id */ - fun addScore(functionId: Score.FunctionId) = apply { body.addScore(functionId) } + fun addScore(functionId: Score.FunctionId) = + apply { + body.addScore(functionId) + } /** Project name and slug */ - fun addScore(projectSlug: Score.ProjectSlug) = apply { body.addScore(projectSlug) } + fun addScore(projectSlug: Score.ProjectSlug) = + apply { + body.addScore(projectSlug) + } /** Global function name */ - fun addScore(globalFunction: Score.GlobalFunction) = apply { body.addScore(globalFunction) } + fun addScore(globalFunction: Score.GlobalFunction) = + apply { + body.addScore(globalFunction) + } /** Prompt session id */ - fun addScore(promptSessionId: Score.PromptSessionId) = apply { - body.addScore(promptSessionId) - } + fun addScore(promptSessionId: Score.PromptSessionId) = + apply { + body.addScore(promptSessionId) + } /** Inline code function */ - fun addScore(inlineCode: Score.InlineCode) = apply { body.addScore(inlineCode) } + fun addScore(inlineCode: Score.InlineCode) = + apply { + body.addScore(inlineCode) + } /** Inline prompt definition */ - fun addScore(inlinePrompt: Score.InlinePrompt) = apply { body.addScore(inlinePrompt) } + fun addScore(inlinePrompt: Score.InlinePrompt) = + apply { + body.addScore(inlinePrompt) + } /** The function to evaluate */ - fun task(task: Task) = apply { body.task(task) } + fun task(task: Task) = + apply { + body.task(task) + } /** The function to evaluate */ - fun task(task: JsonField) = apply { body.task(task) } + fun task(task: JsonField) = + apply { + body.task(task) + } /** Function id */ - fun task(functionId: Task.FunctionId) = apply { body.task(functionId) } + fun task(functionId: Task.FunctionId) = + apply { + body.task(functionId) + } /** Project name and slug */ - fun task(projectSlug: Task.ProjectSlug) = apply { body.task(projectSlug) } + fun task(projectSlug: Task.ProjectSlug) = + apply { + body.task(projectSlug) + } /** Global function name */ - fun task(globalFunction: Task.GlobalFunction) = apply { body.task(globalFunction) } + fun task(globalFunction: Task.GlobalFunction) = + apply { + body.task(globalFunction) + } /** Prompt session id */ - fun task(promptSessionId: Task.PromptSessionId) = apply { body.task(promptSessionId) } + fun task(promptSessionId: Task.PromptSessionId) = + apply { + body.task(promptSessionId) + } /** Inline code function */ - fun task(inlineCode: Task.InlineCode) = apply { body.task(inlineCode) } + fun task(inlineCode: Task.InlineCode) = + apply { + body.task(inlineCode) + } /** Inline prompt definition */ - fun task(inlinePrompt: Task.InlinePrompt) = apply { body.task(inlinePrompt) } + fun task(inlinePrompt: Task.InlinePrompt) = + apply { + body.task(inlinePrompt) + } /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: String?) = apply { - body.baseExperimentId(baseExperimentId) - } + fun baseExperimentId(baseExperimentId: String?) = + apply { + body.baseExperimentId(baseExperimentId) + } /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: Optional) = - baseExperimentId(baseExperimentId.getOrNull()) + fun baseExperimentId(baseExperimentId: Optional) = baseExperimentId(baseExperimentId.getOrNull()) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: JsonField) = apply { - body.baseExperimentId(baseExperimentId) - } + fun baseExperimentId(baseExperimentId: JsonField) = + apply { + body.baseExperimentId(baseExperimentId) + } /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: String?) = apply { - body.baseExperimentName(baseExperimentName) - } + fun baseExperimentName(baseExperimentName: String?) = + apply { + body.baseExperimentName(baseExperimentName) + } /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: Optional) = - baseExperimentName(baseExperimentName.getOrNull()) + fun baseExperimentName(baseExperimentName: Optional) = baseExperimentName(baseExperimentName.getOrNull()) /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: JsonField) = apply { - body.baseExperimentName(baseExperimentName) - } + fun baseExperimentName(baseExperimentName: JsonField) = + apply { + body.baseExperimentName(baseExperimentName) + } /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: String) = apply { body.experimentName(experimentName) } + fun experimentName(experimentName: String) = + apply { + body.experimentName(experimentName) + } /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: JsonField) = apply { - body.experimentName(experimentName) - } + fun experimentName(experimentName: JsonField) = + apply { + body.experimentName(experimentName) + } /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = apply { - body.gitMetadataSettings(gitMetadataSettings) - } + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = + apply { + body.gitMetadataSettings(gitMetadataSettings) + } /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: Optional) = - gitMetadataSettings(gitMetadataSettings.getOrNull()) + fun gitMetadataSettings(gitMetadataSettings: Optional) = gitMetadataSettings(gitMetadataSettings.getOrNull()) /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { - body.gitMetadataSettings(gitMetadataSettings) - } + fun gitMetadataSettings(gitMetadataSettings: JsonField) = + apply { + body.gitMetadataSettings(gitMetadataSettings) + } /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: Boolean?) = apply { body.isPublic(isPublic) } + fun isPublic(isPublic: Boolean?) = + apply { + body.isPublic(isPublic) + } /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) @@ -1058,259 +1157,332 @@ private constructor( fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: JsonField) = apply { body.isPublic(isPublic) } + fun isPublic(isPublic: JsonField) = + apply { + body.isPublic(isPublic) + } /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Double?) = apply { body.maxConcurrency(maxConcurrency) } + fun maxConcurrency(maxConcurrency: Double?) = + apply { + body.maxConcurrency(maxConcurrency) + } /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ fun maxConcurrency(maxConcurrency: Double) = maxConcurrency(maxConcurrency as Double?) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Optional) = - maxConcurrency(maxConcurrency.getOrNull()) + fun maxConcurrency(maxConcurrency: Optional) = maxConcurrency(maxConcurrency.getOrNull()) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: JsonField) = apply { - body.maxConcurrency(maxConcurrency) - } + fun maxConcurrency(maxConcurrency: JsonField) = + apply { + body.maxConcurrency(maxConcurrency) + } /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ - fun metadata(metadata: Metadata) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata) = + apply { + body.metadata(metadata) + } /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: RepoInfo?) = + apply { + body.repoInfo(repoInfo) + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: JsonField) = + apply { + body.repoInfo(repoInfo) + } /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ - fun stream(stream: Boolean) = apply { body.stream(stream) } + fun stream(stream: Boolean) = + apply { + body.stream(stream) + } /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ - fun stream(stream: JsonField) = apply { body.stream(stream) } + fun stream(stream: JsonField) = + apply { + body.stream(stream) + } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ - fun timeout(timeout: Double?) = apply { body.timeout(timeout) } + fun timeout(timeout: Double?) = + apply { + body.timeout(timeout) + } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Double) = timeout(timeout as Double?) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ - fun timeout(timeout: JsonField) = apply { body.timeout(timeout) } + fun timeout(timeout: JsonField) = + apply { + body.timeout(timeout) + } /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ - fun trialCount(trialCount: Double?) = apply { body.trialCount(trialCount) } + fun trialCount(trialCount: Double?) = + apply { + body.trialCount(trialCount) + } /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ - fun trialCount(trialCount: JsonField) = apply { body.trialCount(trialCount) } + fun trialCount(trialCount: JsonField) = + apply { + body.trialCount(trialCount) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + fun putAdditionalQueryParam(key: String, value: String) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) + additionalQueryParams.put(key, value) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EvalCreateParams = - EvalCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + EvalCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) } /** The dataset to use */ @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val datasetId: DatasetId? = null, private val projectDatasetName: ProjectDatasetName? = null, private val _json: JsonValue? = null, + ) { /** Dataset id */ fun datasetId(): Optional = Optional.ofNullable(datasetId) /** Project and dataset name */ - fun projectDatasetName(): Optional = - Optional.ofNullable(projectDatasetName) + fun projectDatasetName(): Optional = Optional.ofNullable(projectDatasetName) fun isDatasetId(): Boolean = datasetId != null @@ -1320,46 +1492,44 @@ private constructor( fun asDatasetId(): DatasetId = datasetId.getOrThrow("datasetId") /** Project and dataset name */ - fun asProjectDatasetName(): ProjectDatasetName = - projectDatasetName.getOrThrow("projectDatasetName") + fun asProjectDatasetName(): ProjectDatasetName = projectDatasetName.getOrThrow("projectDatasetName") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - datasetId != null -> visitor.visitDatasetId(datasetId) - projectDatasetName != null -> visitor.visitProjectDatasetName(projectDatasetName) - else -> visitor.unknown(_json) - } + return when { + datasetId != null -> visitor.visitDatasetId(datasetId) + projectDatasetName != null -> visitor.visitProjectDatasetName(projectDatasetName) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitDatasetId(datasetId: DatasetId) { - datasetId.validate() + datasetId.validate() } override fun visitProjectDatasetName(projectDatasetName: ProjectDatasetName) { - projectDatasetName.validate() + projectDatasetName.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName /* spotless:on */ + return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, projectDatasetName) /* spotless:on */ @@ -1375,15 +1545,18 @@ private constructor( companion object { /** Dataset id */ - @JvmStatic fun ofDatasetId(datasetId: DatasetId) = Data(datasetId = datasetId) + @JvmStatic + fun ofDatasetId(datasetId: DatasetId) = Data(datasetId = datasetId) /** Project and dataset name */ @JvmStatic - fun ofProjectDatasetName(projectDatasetName: ProjectDatasetName) = - Data(projectDatasetName = projectDatasetName) + fun ofProjectDatasetName(projectDatasetName: ProjectDatasetName) = Data(projectDatasetName = projectDatasetName) } - /** An interface that defines how to map each variant of [Data] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Data] to a value of type + * [T]. + */ interface Visitor { /** Dataset id */ @@ -1395,62 +1568,52 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(datasetId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(projectDatasetName = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(datasetId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(projectDatasetName = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.datasetId != null -> generator.writeObject(value.datasetId) - value.projectDatasetName != null -> - generator.writeObject(value.projectDatasetName) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.datasetId != null -> generator.writeObject(value.datasetId) + value.projectDatasetName != null -> generator.writeObject(value.projectDatasetName) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } /** Dataset id */ @NoAutoDetect - class DatasetId - @JsonCreator - private constructor( - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class DatasetId @JsonCreator private constructor( + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun datasetId(): String = datasetId.getRequired("dataset_id") @@ -1465,14 +1628,15 @@ private constructor( private var validated: Boolean = false - fun validate(): DatasetId = apply { - if (validated) { - return@apply - } + fun validate(): DatasetId = + apply { + if (validated) { + return@apply + } - datasetId() - validated = true - } + datasetId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1482,11 +1646,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetId]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetId]. */ @@ -1496,50 +1662,59 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetId: DatasetId) = apply { - this.datasetId = datasetId.datasetId - additionalProperties = datasetId.additionalProperties.toMutableMap() - } + internal fun from(datasetId: DatasetId) = + apply { + this.datasetId = datasetId.datasetId + additionalProperties = datasetId.additionalProperties.toMutableMap() + } fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): DatasetId = DatasetId( - checkRequired("datasetId", datasetId), - additionalProperties.toImmutable(), + checkRequired( + "datasetId", datasetId + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1548,23 +1723,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" } /** Project and dataset name */ @NoAutoDetect - class ProjectDatasetName - @JsonCreator - private constructor( - @JsonProperty("dataset_name") - @ExcludeMissing - private val datasetName: JsonField = JsonMissing.of(), - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class ProjectDatasetName @JsonCreator private constructor( + @JsonProperty("dataset_name") @ExcludeMissing private val datasetName: JsonField = JsonMissing.of(), + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun datasetName(): String = datasetName.getRequired("dataset_name") @@ -1585,15 +1753,16 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectDatasetName = apply { - if (validated) { - return@apply - } + fun validate(): ProjectDatasetName = + apply { + if (validated) { + return@apply + } - datasetName() - projectName() - validated = true - } + datasetName() + projectName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1603,12 +1772,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectDatasetName]. * * The following fields are required: + * * ```java * .datasetName() * .projectName() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectDatasetName]. */ @@ -1619,60 +1790,71 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectDatasetName: ProjectDatasetName) = apply { - datasetName = projectDatasetName.datasetName - projectName = projectDatasetName.projectName - additionalProperties = projectDatasetName.additionalProperties.toMutableMap() - } + internal fun from(projectDatasetName: ProjectDatasetName) = + apply { + datasetName = projectDatasetName.datasetName + projectName = projectDatasetName.projectName + additionalProperties = projectDatasetName.additionalProperties.toMutableMap() + } fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) - fun datasetName(datasetName: JsonField) = apply { - this.datasetName = datasetName - } + fun datasetName(datasetName: JsonField) = + apply { + this.datasetName = datasetName + } fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - fun projectName(projectName: JsonField) = apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectDatasetName = ProjectDatasetName( - checkRequired("datasetName", datasetName), - checkRequired("projectName", projectName), - additionalProperties.toImmutable(), + checkRequired( + "datasetName", datasetName + ), + checkRequired( + "projectName", projectName + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1681,16 +1863,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, additionalProperties=$additionalProperties}" } } /** The function to evaluate */ @JsonDeserialize(using = Score.Deserializer::class) @JsonSerialize(using = Score.Serializer::class) - class Score - private constructor( + class Score private constructor( private val functionId: FunctionId? = null, private val projectSlug: ProjectSlug? = null, private val globalFunction: GlobalFunction? = null, @@ -1698,6 +1878,7 @@ private constructor( private val inlineCode: InlineCode? = null, private val inlinePrompt: InlinePrompt? = null, private val _json: JsonValue? = null, + ) { /** Function id */ @@ -1751,60 +1932,59 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - functionId != null -> visitor.visitFunctionId(functionId) - projectSlug != null -> visitor.visitProjectSlug(projectSlug) - globalFunction != null -> visitor.visitGlobalFunction(globalFunction) - promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) - inlineCode != null -> visitor.visitInlineCode(inlineCode) - inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) - else -> visitor.unknown(_json) - } + return when { + functionId != null -> visitor.visitFunctionId(functionId) + projectSlug != null -> visitor.visitProjectSlug(projectSlug) + globalFunction != null -> visitor.visitGlobalFunction(globalFunction) + promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) + inlineCode != null -> visitor.visitInlineCode(inlineCode) + inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Score = apply { - if (validated) { - return@apply - } + fun validate(): Score = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitFunctionId(functionId: FunctionId) { - functionId.validate() + functionId.validate() } override fun visitProjectSlug(projectSlug: ProjectSlug) { - projectSlug.validate() + projectSlug.validate() } override fun visitGlobalFunction(globalFunction: GlobalFunction) { - globalFunction.validate() + globalFunction.validate() } override fun visitPromptSessionId(promptSessionId: PromptSessionId) { - promptSessionId.validate() + promptSessionId.validate() } override fun visitInlineCode(inlineCode: InlineCode) { - inlineCode.validate() + inlineCode.validate() } override fun visitInlinePrompt(inlinePrompt: InlinePrompt) { - inlinePrompt.validate() + inlinePrompt.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Score && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ + return /* spotless:off */ other is Score && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ @@ -1824,7 +2004,8 @@ private constructor( companion object { /** Function id */ - @JvmStatic fun ofFunctionId(functionId: FunctionId) = Score(functionId = functionId) + @JvmStatic + fun ofFunctionId(functionId: FunctionId) = Score(functionId = functionId) /** Project name and slug */ @JvmStatic @@ -1832,23 +2013,25 @@ private constructor( /** Global function name */ @JvmStatic - fun ofGlobalFunction(globalFunction: GlobalFunction) = - Score(globalFunction = globalFunction) + fun ofGlobalFunction(globalFunction: GlobalFunction) = Score(globalFunction = globalFunction) /** Prompt session id */ @JvmStatic - fun ofPromptSessionId(promptSessionId: PromptSessionId) = - Score(promptSessionId = promptSessionId) + fun ofPromptSessionId(promptSessionId: PromptSessionId) = Score(promptSessionId = promptSessionId) /** Inline code function */ - @JvmStatic fun ofInlineCode(inlineCode: InlineCode) = Score(inlineCode = inlineCode) + @JvmStatic + fun ofInlineCode(inlineCode: InlineCode) = Score(inlineCode = inlineCode) /** Inline prompt definition */ @JvmStatic fun ofInlinePrompt(inlinePrompt: InlinePrompt) = Score(inlinePrompt = inlinePrompt) } - /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Score] to a value of type + * [T]. + */ interface Visitor { /** Function id */ @@ -1872,85 +2055,69 @@ private constructor( /** * Maps an unknown variant of [Score] to a value of type [T]. * - * An instance of [Score] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Score] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Score: $json") + throw BraintrustInvalidDataException("Unknown Score: $json") } } internal class Deserializer : BaseDeserializer(Score::class) { override fun ObjectCodec.deserialize(node: JsonNode): Score { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(functionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(projectSlug = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(globalFunction = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(promptSessionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(inlineCode = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(inlinePrompt = it, _json = json) - } - - return Score(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(functionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(projectSlug = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(globalFunction = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(promptSessionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(inlineCode = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(inlinePrompt = it, _json = json) + } + + return Score(_json = json) } } internal class Serializer : BaseSerializer(Score::class) { - override fun serialize( - value: Score, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.functionId != null -> generator.writeObject(value.functionId) - value.projectSlug != null -> generator.writeObject(value.projectSlug) - value.globalFunction != null -> generator.writeObject(value.globalFunction) - value.promptSessionId != null -> generator.writeObject(value.promptSessionId) - value.inlineCode != null -> generator.writeObject(value.inlineCode) - value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Score") - } + override fun serialize(value: Score, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.functionId != null -> generator.writeObject(value.functionId) + value.projectSlug != null -> generator.writeObject(value.projectSlug) + value.globalFunction != null -> generator.writeObject(value.globalFunction) + value.promptSessionId != null -> generator.writeObject(value.promptSessionId) + value.inlineCode != null -> generator.writeObject(value.inlineCode) + value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Score") + } } } /** Function id */ @NoAutoDetect - class FunctionId - @JsonCreator - private constructor( - @JsonProperty("function_id") - @ExcludeMissing - private val functionId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class FunctionId @JsonCreator private constructor( + @JsonProperty("function_id") @ExcludeMissing private val functionId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The ID of the function */ @@ -1965,7 +2132,9 @@ private constructor( fun _functionId(): JsonField = functionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1973,15 +2142,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionId = apply { - if (validated) { - return@apply - } + fun validate(): FunctionId = + apply { + if (validated) { + return@apply + } - functionId() - version() - validated = true - } + functionId() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1991,11 +2161,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [FunctionId]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionId]. */ @@ -2006,62 +2178,73 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionId: FunctionId) = apply { - this.functionId = functionId.functionId - version = functionId.version - additionalProperties = functionId.additionalProperties.toMutableMap() - } + internal fun from(functionId: FunctionId) = + apply { + this.functionId = functionId.functionId + version = functionId.version + additionalProperties = functionId.additionalProperties.toMutableMap() + } /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) /** The ID of the function */ - fun functionId(functionId: JsonField) = apply { - this.functionId = functionId - } + fun functionId(functionId: JsonField) = + apply { + this.functionId = functionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionId = FunctionId( - checkRequired("functionId", functionId), - version, - additionalProperties.toImmutable(), + checkRequired( + "functionId", functionId + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2070,26 +2253,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" } /** Project name and slug */ @NoAutoDetect - class ProjectSlug - @JsonCreator - private constructor( - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class ProjectSlug @JsonCreator private constructor( + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the project containing the function */ @@ -2107,10 +2281,14 @@ private constructor( fun _projectName(): JsonField = projectName /** The slug of the function */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2118,16 +2296,17 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectSlug = apply { - if (validated) { - return@apply - } + fun validate(): ProjectSlug = + apply { + if (validated) { + return@apply + } - projectName() - slug() - version() - validated = true - } + projectName() + slug() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2137,12 +2316,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectSlug]. * * The following fields are required: + * * ```java * .projectName() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectSlug]. */ @@ -2154,70 +2335,86 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectSlug: ProjectSlug) = apply { - projectName = projectSlug.projectName - slug = projectSlug.slug - version = projectSlug.version - additionalProperties = projectSlug.additionalProperties.toMutableMap() - } + internal fun from(projectSlug: ProjectSlug) = + apply { + projectName = projectSlug.projectName + slug = projectSlug.slug + version = projectSlug.version + additionalProperties = projectSlug.additionalProperties.toMutableMap() + } /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** The name of the project containing the function */ - fun projectName(projectName: JsonField) = apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } /** The slug of the function */ fun slug(slug: String) = slug(JsonField.of(slug)) /** The slug of the function */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectSlug = ProjectSlug( - checkRequired("projectName", projectName), - checkRequired("slug", slug), - version, - additionalProperties.toImmutable(), + checkRequired( + "projectName", projectName + ), + checkRequired( + "slug", slug + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2226,20 +2423,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" } /** Global function name */ @NoAutoDetect - class GlobalFunction - @JsonCreator - private constructor( - @JsonProperty("global_function") - @ExcludeMissing - private val globalFunction: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class GlobalFunction @JsonCreator private constructor( + @JsonProperty("global_function") @ExcludeMissing private val globalFunction: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** @@ -2262,14 +2454,15 @@ private constructor( private var validated: Boolean = false - fun validate(): GlobalFunction = apply { - if (validated) { - return@apply - } + fun validate(): GlobalFunction = + apply { + if (validated) { + return@apply + } - globalFunction() - validated = true - } + globalFunction() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2279,11 +2472,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GlobalFunction]. * * The following fields are required: + * * ```java * .globalFunction() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GlobalFunction]. */ @@ -2293,61 +2488,67 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(globalFunction: GlobalFunction) = apply { - this.globalFunction = globalFunction.globalFunction - additionalProperties = globalFunction.additionalProperties.toMutableMap() - } + internal fun from(globalFunction: GlobalFunction) = + apply { + this.globalFunction = globalFunction.globalFunction + additionalProperties = globalFunction.additionalProperties.toMutableMap() + } /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: String) = - globalFunction(JsonField.of(globalFunction)) + fun globalFunction(globalFunction: String) = globalFunction(JsonField.of(globalFunction)) /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: JsonField) = apply { - this.globalFunction = globalFunction - } + fun globalFunction(globalFunction: JsonField) = + apply { + this.globalFunction = globalFunction + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GlobalFunction = GlobalFunction( - checkRequired("globalFunction", globalFunction), - additionalProperties.toImmutable(), + checkRequired( + "globalFunction", globalFunction + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2356,31 +2557,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" + override fun toString() = "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" } /** Prompt session id */ @NoAutoDetect - class PromptSessionId - @JsonCreator - private constructor( - @JsonProperty("prompt_session_function_id") - @ExcludeMissing - private val promptSessionFunctionId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_session_id") - @ExcludeMissing - private val promptSessionId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class PromptSessionId @JsonCreator private constructor( + @JsonProperty("prompt_session_function_id") @ExcludeMissing private val promptSessionFunctionId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_session_id") @ExcludeMissing private val promptSessionId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(): String = - promptSessionFunctionId.getRequired("prompt_session_function_id") + fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") /** The ID of the prompt session */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") @@ -2399,7 +2590,9 @@ private constructor( fun _promptSessionId(): JsonField = promptSessionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2407,16 +2600,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptSessionId = apply { - if (validated) { - return@apply - } + fun validate(): PromptSessionId = + apply { + if (validated) { + return@apply + } - promptSessionFunctionId() - promptSessionId() - version() - validated = true - } + promptSessionFunctionId() + promptSessionId() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2426,12 +2620,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptSessionId]. * * The following fields are required: + * * ```java * .promptSessionFunctionId() * .promptSessionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptSessionId]. */ @@ -2443,74 +2639,86 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptSessionId: PromptSessionId) = apply { - promptSessionFunctionId = promptSessionId.promptSessionFunctionId - this.promptSessionId = promptSessionId.promptSessionId - version = promptSessionId.version - additionalProperties = promptSessionId.additionalProperties.toMutableMap() - } + internal fun from(promptSessionId: PromptSessionId) = + apply { + promptSessionFunctionId = promptSessionId.promptSessionFunctionId + this.promptSessionId = promptSessionId.promptSessionId + version = promptSessionId.version + additionalProperties = promptSessionId.additionalProperties.toMutableMap() + } /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: String) = - promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) + fun promptSessionFunctionId(promptSessionFunctionId: String) = promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { - this.promptSessionFunctionId = promptSessionFunctionId - } + fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = + apply { + this.promptSessionFunctionId = promptSessionFunctionId + } /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: String) = - promptSessionId(JsonField.of(promptSessionId)) + fun promptSessionId(promptSessionId: String) = promptSessionId(JsonField.of(promptSessionId)) /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: JsonField) = apply { - this.promptSessionId = promptSessionId - } + fun promptSessionId(promptSessionId: JsonField) = + apply { + this.promptSessionId = promptSessionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptSessionId = PromptSessionId( - checkRequired("promptSessionFunctionId", promptSessionFunctionId), - checkRequired("promptSessionId", promptSessionId), - version, - additionalProperties.toImmutable(), + checkRequired( + "promptSessionFunctionId", promptSessionFunctionId + ), + checkRequired( + "promptSessionId", promptSessionId + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2519,26 +2727,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" } /** Inline code function */ @NoAutoDetect - class InlineCode - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("inline_context") - @ExcludeMissing - private val inlineContext: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlineCode @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("inline_context") @ExcludeMissing private val inlineContext: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The inline code to execute */ @@ -2550,14 +2749,18 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The inline code to execute */ - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext(): JsonField = inlineContext /** The name of the inline code function */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2565,16 +2768,17 @@ private constructor( private var validated: Boolean = false - fun validate(): InlineCode = apply { - if (validated) { - return@apply - } + fun validate(): InlineCode = + apply { + if (validated) { + return@apply + } - code() - inlineContext().validate() - name() - validated = true - } + code() + inlineContext().validate() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2584,12 +2788,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlineCode]. * * The following fields are required: + * * ```java * .code() * .inlineContext() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlineCode]. */ @@ -2601,25 +2807,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineCode: InlineCode) = apply { - code = inlineCode.code - inlineContext = inlineCode.inlineContext - name = inlineCode.name - additionalProperties = inlineCode.additionalProperties.toMutableMap() - } + internal fun from(inlineCode: InlineCode) = + apply { + code = inlineCode.code + inlineContext = inlineCode.inlineContext + name = inlineCode.name + additionalProperties = inlineCode.additionalProperties.toMutableMap() + } /** The inline code to execute */ fun code(code: String) = code(JsonField.of(code)) /** The inline code to execute */ - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun inlineContext(inlineContext: InlineContext) = - inlineContext(JsonField.of(inlineContext)) + fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) - fun inlineContext(inlineContext: JsonField) = apply { - this.inlineContext = inlineContext - } + fun inlineContext(inlineContext: JsonField) = + apply { + this.inlineContext = inlineContext + } /** The name of the inline code function */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -2628,51 +2838,56 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline code function */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineCode = InlineCode( - checkRequired("code", code), - checkRequired("inlineContext", inlineContext), - name, - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "inlineContext", inlineContext + ), + name, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InlineContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlineContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -2683,7 +2898,9 @@ private constructor( @ExcludeMissing fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2691,15 +2908,16 @@ private constructor( private var validated: Boolean = false - fun validate(): InlineContext = apply { - if (validated) { - return@apply - } + fun validate(): InlineContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2709,12 +2927,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlineContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlineContext]. */ @@ -2725,61 +2945,77 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineContext: InlineContext) = apply { - runtime = inlineContext.runtime - version = inlineContext.version - additionalProperties = inlineContext.additionalProperties.toMutableMap() - } + internal fun from(inlineContext: InlineContext) = + apply { + runtime = inlineContext.runtime + version = inlineContext.version + additionalProperties = inlineContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { this.runtime = runtime } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineContext = InlineContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -2803,18 +3039,17 @@ private constructor( * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Runtime] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an unknown - * value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2822,8 +3057,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2835,11 +3070,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a - * not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2854,20 +3089,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does - * not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2876,11 +3108,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2889,16 +3121,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2907,28 +3138,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ @NoAutoDetect - class InlinePrompt - @JsonCreator - private constructor( - @JsonProperty("inline_prompt") - @ExcludeMissing - private val inlinePrompt: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlinePrompt @JsonCreator private constructor( + @JsonProperty("inline_prompt") @ExcludeMissing private val inlinePrompt: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The prompt, model, and its parameters */ - fun inlinePrompt(): Optional = - Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) + fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) /** The name of the inline prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -2939,7 +3162,9 @@ private constructor( fun _inlinePrompt(): JsonField = inlinePrompt /** The name of the inline prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2947,15 +3172,16 @@ private constructor( private var validated: Boolean = false - fun validate(): InlinePrompt = apply { - if (validated) { - return@apply - } + fun validate(): InlinePrompt = + apply { + if (validated) { + return@apply + } - inlinePrompt().ifPresent { it.validate() } - name() - validated = true - } + inlinePrompt().ifPresent { it.validate() } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2965,11 +3191,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlinePrompt]. * * The following fields are required: + * * ```java * .inlinePrompt() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlinePrompt]. */ @@ -2980,24 +3208,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlinePrompt: InlinePrompt) = apply { - this.inlinePrompt = inlinePrompt.inlinePrompt - name = inlinePrompt.name - additionalProperties = inlinePrompt.additionalProperties.toMutableMap() - } + internal fun from(inlinePrompt: InlinePrompt) = + apply { + this.inlinePrompt = inlinePrompt.inlinePrompt + name = inlinePrompt.name + additionalProperties = inlinePrompt.additionalProperties.toMutableMap() + } /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: PromptData?) = - inlinePrompt(JsonField.ofNullable(inlinePrompt)) + fun inlinePrompt(inlinePrompt: PromptData?) = inlinePrompt(JsonField.ofNullable(inlinePrompt)) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: Optional) = - inlinePrompt(inlinePrompt.getOrNull()) + fun inlinePrompt(inlinePrompt: Optional) = inlinePrompt(inlinePrompt.getOrNull()) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: JsonField) = apply { - this.inlinePrompt = inlinePrompt - } + fun inlinePrompt(inlinePrompt: JsonField) = + apply { + this.inlinePrompt = inlinePrompt + } /** The name of the inline prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -3006,44 +3234,53 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlinePrompt = InlinePrompt( - checkRequired("inlinePrompt", inlinePrompt), - name, - additionalProperties.toImmutable(), + checkRequired( + "inlinePrompt", inlinePrompt + ), + name, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3052,16 +3289,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" } } /** The function to evaluate */ @JsonDeserialize(using = Task.Deserializer::class) @JsonSerialize(using = Task.Serializer::class) - class Task - private constructor( + class Task private constructor( private val functionId: FunctionId? = null, private val projectSlug: ProjectSlug? = null, private val globalFunction: GlobalFunction? = null, @@ -3069,6 +3304,7 @@ private constructor( private val inlineCode: InlineCode? = null, private val inlinePrompt: InlinePrompt? = null, private val _json: JsonValue? = null, + ) { /** Function id */ @@ -3122,60 +3358,59 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - functionId != null -> visitor.visitFunctionId(functionId) - projectSlug != null -> visitor.visitProjectSlug(projectSlug) - globalFunction != null -> visitor.visitGlobalFunction(globalFunction) - promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) - inlineCode != null -> visitor.visitInlineCode(inlineCode) - inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) - else -> visitor.unknown(_json) - } + return when { + functionId != null -> visitor.visitFunctionId(functionId) + projectSlug != null -> visitor.visitProjectSlug(projectSlug) + globalFunction != null -> visitor.visitGlobalFunction(globalFunction) + promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) + inlineCode != null -> visitor.visitInlineCode(inlineCode) + inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Task = apply { - if (validated) { - return@apply - } + fun validate(): Task = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitFunctionId(functionId: FunctionId) { - functionId.validate() + functionId.validate() } override fun visitProjectSlug(projectSlug: ProjectSlug) { - projectSlug.validate() + projectSlug.validate() } override fun visitGlobalFunction(globalFunction: GlobalFunction) { - globalFunction.validate() + globalFunction.validate() } override fun visitPromptSessionId(promptSessionId: PromptSessionId) { - promptSessionId.validate() + promptSessionId.validate() } override fun visitInlineCode(inlineCode: InlineCode) { - inlineCode.validate() + inlineCode.validate() } override fun visitInlinePrompt(inlinePrompt: InlinePrompt) { - inlinePrompt.validate() + inlinePrompt.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Task && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ + return /* spotless:off */ other is Task && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ @@ -3195,30 +3430,34 @@ private constructor( companion object { /** Function id */ - @JvmStatic fun ofFunctionId(functionId: FunctionId) = Task(functionId = functionId) + @JvmStatic + fun ofFunctionId(functionId: FunctionId) = Task(functionId = functionId) /** Project name and slug */ - @JvmStatic fun ofProjectSlug(projectSlug: ProjectSlug) = Task(projectSlug = projectSlug) + @JvmStatic + fun ofProjectSlug(projectSlug: ProjectSlug) = Task(projectSlug = projectSlug) /** Global function name */ @JvmStatic - fun ofGlobalFunction(globalFunction: GlobalFunction) = - Task(globalFunction = globalFunction) + fun ofGlobalFunction(globalFunction: GlobalFunction) = Task(globalFunction = globalFunction) /** Prompt session id */ @JvmStatic - fun ofPromptSessionId(promptSessionId: PromptSessionId) = - Task(promptSessionId = promptSessionId) + fun ofPromptSessionId(promptSessionId: PromptSessionId) = Task(promptSessionId = promptSessionId) /** Inline code function */ - @JvmStatic fun ofInlineCode(inlineCode: InlineCode) = Task(inlineCode = inlineCode) + @JvmStatic + fun ofInlineCode(inlineCode: InlineCode) = Task(inlineCode = inlineCode) /** Inline prompt definition */ @JvmStatic fun ofInlinePrompt(inlinePrompt: InlinePrompt) = Task(inlinePrompt = inlinePrompt) } - /** An interface that defines how to map each variant of [Task] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Task] to a value of type + * [T]. + */ interface Visitor { /** Function id */ @@ -3242,84 +3481,69 @@ private constructor( /** * Maps an unknown variant of [Task] to a value of type [T]. * - * An instance of [Task] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Task] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Task: $json") + throw BraintrustInvalidDataException("Unknown Task: $json") } } internal class Deserializer : BaseDeserializer(Task::class) { override fun ObjectCodec.deserialize(node: JsonNode): Task { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(functionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(projectSlug = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(globalFunction = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(promptSessionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(inlineCode = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(inlinePrompt = it, _json = json) - } - - return Task(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(functionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(projectSlug = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(globalFunction = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(promptSessionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(inlineCode = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(inlinePrompt = it, _json = json) + } + + return Task(_json = json) } } internal class Serializer : BaseSerializer(Task::class) { - override fun serialize( - value: Task, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.functionId != null -> generator.writeObject(value.functionId) - value.projectSlug != null -> generator.writeObject(value.projectSlug) - value.globalFunction != null -> generator.writeObject(value.globalFunction) - value.promptSessionId != null -> generator.writeObject(value.promptSessionId) - value.inlineCode != null -> generator.writeObject(value.inlineCode) - value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Task") - } + override fun serialize(value: Task, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.functionId != null -> generator.writeObject(value.functionId) + value.projectSlug != null -> generator.writeObject(value.projectSlug) + value.globalFunction != null -> generator.writeObject(value.globalFunction) + value.promptSessionId != null -> generator.writeObject(value.promptSessionId) + value.inlineCode != null -> generator.writeObject(value.inlineCode) + value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Task") + } } } /** Function id */ @NoAutoDetect - class FunctionId - @JsonCreator - private constructor( - @JsonProperty("function_id") - @ExcludeMissing - private val functionId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class FunctionId @JsonCreator private constructor( + @JsonProperty("function_id") @ExcludeMissing private val functionId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The ID of the function */ @@ -3334,7 +3558,9 @@ private constructor( fun _functionId(): JsonField = functionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -3342,15 +3568,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionId = apply { - if (validated) { - return@apply - } + fun validate(): FunctionId = + apply { + if (validated) { + return@apply + } - functionId() - version() - validated = true - } + functionId() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3360,11 +3587,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [FunctionId]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionId]. */ @@ -3375,62 +3604,73 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionId: FunctionId) = apply { - this.functionId = functionId.functionId - version = functionId.version - additionalProperties = functionId.additionalProperties.toMutableMap() - } + internal fun from(functionId: FunctionId) = + apply { + this.functionId = functionId.functionId + version = functionId.version + additionalProperties = functionId.additionalProperties.toMutableMap() + } /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) /** The ID of the function */ - fun functionId(functionId: JsonField) = apply { - this.functionId = functionId - } + fun functionId(functionId: JsonField) = + apply { + this.functionId = functionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionId = FunctionId( - checkRequired("functionId", functionId), - version, - additionalProperties.toImmutable(), + checkRequired( + "functionId", functionId + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3439,26 +3679,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" } /** Project name and slug */ @NoAutoDetect - class ProjectSlug - @JsonCreator - private constructor( - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class ProjectSlug @JsonCreator private constructor( + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the project containing the function */ @@ -3476,10 +3707,14 @@ private constructor( fun _projectName(): JsonField = projectName /** The slug of the function */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -3487,16 +3722,17 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectSlug = apply { - if (validated) { - return@apply - } + fun validate(): ProjectSlug = + apply { + if (validated) { + return@apply + } - projectName() - slug() - version() - validated = true - } + projectName() + slug() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3506,12 +3742,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectSlug]. * * The following fields are required: + * * ```java * .projectName() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectSlug]. */ @@ -3523,70 +3761,86 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectSlug: ProjectSlug) = apply { - projectName = projectSlug.projectName - slug = projectSlug.slug - version = projectSlug.version - additionalProperties = projectSlug.additionalProperties.toMutableMap() - } + internal fun from(projectSlug: ProjectSlug) = + apply { + projectName = projectSlug.projectName + slug = projectSlug.slug + version = projectSlug.version + additionalProperties = projectSlug.additionalProperties.toMutableMap() + } /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** The name of the project containing the function */ - fun projectName(projectName: JsonField) = apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } /** The slug of the function */ fun slug(slug: String) = slug(JsonField.of(slug)) /** The slug of the function */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectSlug = ProjectSlug( - checkRequired("projectName", projectName), - checkRequired("slug", slug), - version, - additionalProperties.toImmutable(), + checkRequired( + "projectName", projectName + ), + checkRequired( + "slug", slug + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3595,20 +3849,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" } /** Global function name */ @NoAutoDetect - class GlobalFunction - @JsonCreator - private constructor( - @JsonProperty("global_function") - @ExcludeMissing - private val globalFunction: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class GlobalFunction @JsonCreator private constructor( + @JsonProperty("global_function") @ExcludeMissing private val globalFunction: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** @@ -3631,14 +3880,15 @@ private constructor( private var validated: Boolean = false - fun validate(): GlobalFunction = apply { - if (validated) { - return@apply - } + fun validate(): GlobalFunction = + apply { + if (validated) { + return@apply + } - globalFunction() - validated = true - } + globalFunction() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3648,11 +3898,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GlobalFunction]. * * The following fields are required: + * * ```java * .globalFunction() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GlobalFunction]. */ @@ -3662,61 +3914,67 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(globalFunction: GlobalFunction) = apply { - this.globalFunction = globalFunction.globalFunction - additionalProperties = globalFunction.additionalProperties.toMutableMap() - } + internal fun from(globalFunction: GlobalFunction) = + apply { + this.globalFunction = globalFunction.globalFunction + additionalProperties = globalFunction.additionalProperties.toMutableMap() + } /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: String) = - globalFunction(JsonField.of(globalFunction)) + fun globalFunction(globalFunction: String) = globalFunction(JsonField.of(globalFunction)) /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: JsonField) = apply { - this.globalFunction = globalFunction - } + fun globalFunction(globalFunction: JsonField) = + apply { + this.globalFunction = globalFunction + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GlobalFunction = GlobalFunction( - checkRequired("globalFunction", globalFunction), - additionalProperties.toImmutable(), + checkRequired( + "globalFunction", globalFunction + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3725,31 +3983,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" + override fun toString() = "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" } /** Prompt session id */ @NoAutoDetect - class PromptSessionId - @JsonCreator - private constructor( - @JsonProperty("prompt_session_function_id") - @ExcludeMissing - private val promptSessionFunctionId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_session_id") - @ExcludeMissing - private val promptSessionId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class PromptSessionId @JsonCreator private constructor( + @JsonProperty("prompt_session_function_id") @ExcludeMissing private val promptSessionFunctionId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_session_id") @ExcludeMissing private val promptSessionId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(): String = - promptSessionFunctionId.getRequired("prompt_session_function_id") + fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") /** The ID of the prompt session */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") @@ -3768,7 +4016,9 @@ private constructor( fun _promptSessionId(): JsonField = promptSessionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -3776,16 +4026,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptSessionId = apply { - if (validated) { - return@apply - } + fun validate(): PromptSessionId = + apply { + if (validated) { + return@apply + } - promptSessionFunctionId() - promptSessionId() - version() - validated = true - } + promptSessionFunctionId() + promptSessionId() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3795,12 +4046,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptSessionId]. * * The following fields are required: + * * ```java * .promptSessionFunctionId() * .promptSessionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptSessionId]. */ @@ -3812,74 +4065,86 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptSessionId: PromptSessionId) = apply { - promptSessionFunctionId = promptSessionId.promptSessionFunctionId - this.promptSessionId = promptSessionId.promptSessionId - version = promptSessionId.version - additionalProperties = promptSessionId.additionalProperties.toMutableMap() - } + internal fun from(promptSessionId: PromptSessionId) = + apply { + promptSessionFunctionId = promptSessionId.promptSessionFunctionId + this.promptSessionId = promptSessionId.promptSessionId + version = promptSessionId.version + additionalProperties = promptSessionId.additionalProperties.toMutableMap() + } /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: String) = - promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) + fun promptSessionFunctionId(promptSessionFunctionId: String) = promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { - this.promptSessionFunctionId = promptSessionFunctionId - } + fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = + apply { + this.promptSessionFunctionId = promptSessionFunctionId + } /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: String) = - promptSessionId(JsonField.of(promptSessionId)) + fun promptSessionId(promptSessionId: String) = promptSessionId(JsonField.of(promptSessionId)) /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: JsonField) = apply { - this.promptSessionId = promptSessionId - } + fun promptSessionId(promptSessionId: JsonField) = + apply { + this.promptSessionId = promptSessionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptSessionId = PromptSessionId( - checkRequired("promptSessionFunctionId", promptSessionFunctionId), - checkRequired("promptSessionId", promptSessionId), - version, - additionalProperties.toImmutable(), + checkRequired( + "promptSessionFunctionId", promptSessionFunctionId + ), + checkRequired( + "promptSessionId", promptSessionId + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3888,26 +4153,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" } /** Inline code function */ @NoAutoDetect - class InlineCode - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("inline_context") - @ExcludeMissing - private val inlineContext: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlineCode @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("inline_context") @ExcludeMissing private val inlineContext: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The inline code to execute */ @@ -3919,14 +4175,18 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The inline code to execute */ - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext(): JsonField = inlineContext /** The name of the inline code function */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -3934,16 +4194,17 @@ private constructor( private var validated: Boolean = false - fun validate(): InlineCode = apply { - if (validated) { - return@apply - } + fun validate(): InlineCode = + apply { + if (validated) { + return@apply + } - code() - inlineContext().validate() - name() - validated = true - } + code() + inlineContext().validate() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3953,12 +4214,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlineCode]. * * The following fields are required: + * * ```java * .code() * .inlineContext() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlineCode]. */ @@ -3970,25 +4233,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineCode: InlineCode) = apply { - code = inlineCode.code - inlineContext = inlineCode.inlineContext - name = inlineCode.name - additionalProperties = inlineCode.additionalProperties.toMutableMap() - } + internal fun from(inlineCode: InlineCode) = + apply { + code = inlineCode.code + inlineContext = inlineCode.inlineContext + name = inlineCode.name + additionalProperties = inlineCode.additionalProperties.toMutableMap() + } /** The inline code to execute */ fun code(code: String) = code(JsonField.of(code)) /** The inline code to execute */ - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun inlineContext(inlineContext: InlineContext) = - inlineContext(JsonField.of(inlineContext)) + fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) - fun inlineContext(inlineContext: JsonField) = apply { - this.inlineContext = inlineContext - } + fun inlineContext(inlineContext: JsonField) = + apply { + this.inlineContext = inlineContext + } /** The name of the inline code function */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -3997,51 +4264,56 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline code function */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineCode = InlineCode( - checkRequired("code", code), - checkRequired("inlineContext", inlineContext), - name, - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "inlineContext", inlineContext + ), + name, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InlineContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlineContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -4052,7 +4324,9 @@ private constructor( @ExcludeMissing fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -4060,15 +4334,16 @@ private constructor( private var validated: Boolean = false - fun validate(): InlineContext = apply { - if (validated) { - return@apply - } + fun validate(): InlineContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -4078,12 +4353,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlineContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlineContext]. */ @@ -4094,61 +4371,77 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineContext: InlineContext) = apply { - runtime = inlineContext.runtime - version = inlineContext.version - additionalProperties = inlineContext.additionalProperties.toMutableMap() - } + internal fun from(inlineContext: InlineContext) = + apply { + runtime = inlineContext.runtime + version = inlineContext.version + additionalProperties = inlineContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { this.runtime = runtime } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineContext = InlineContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -4172,18 +4465,17 @@ private constructor( * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Runtime] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an unknown - * value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4191,8 +4483,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -4204,11 +4496,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a - * not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -4223,20 +4515,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does - * not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4245,11 +4534,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4258,16 +4547,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4276,28 +4564,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ @NoAutoDetect - class InlinePrompt - @JsonCreator - private constructor( - @JsonProperty("inline_prompt") - @ExcludeMissing - private val inlinePrompt: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlinePrompt @JsonCreator private constructor( + @JsonProperty("inline_prompt") @ExcludeMissing private val inlinePrompt: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The prompt, model, and its parameters */ - fun inlinePrompt(): Optional = - Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) + fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) /** The name of the inline prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -4308,7 +4588,9 @@ private constructor( fun _inlinePrompt(): JsonField = inlinePrompt /** The name of the inline prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -4316,15 +4598,16 @@ private constructor( private var validated: Boolean = false - fun validate(): InlinePrompt = apply { - if (validated) { - return@apply - } + fun validate(): InlinePrompt = + apply { + if (validated) { + return@apply + } - inlinePrompt().ifPresent { it.validate() } - name() - validated = true - } + inlinePrompt().ifPresent { it.validate() } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -4334,11 +4617,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlinePrompt]. * * The following fields are required: + * * ```java * .inlinePrompt() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlinePrompt]. */ @@ -4349,24 +4634,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlinePrompt: InlinePrompt) = apply { - this.inlinePrompt = inlinePrompt.inlinePrompt - name = inlinePrompt.name - additionalProperties = inlinePrompt.additionalProperties.toMutableMap() - } + internal fun from(inlinePrompt: InlinePrompt) = + apply { + this.inlinePrompt = inlinePrompt.inlinePrompt + name = inlinePrompt.name + additionalProperties = inlinePrompt.additionalProperties.toMutableMap() + } /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: PromptData?) = - inlinePrompt(JsonField.ofNullable(inlinePrompt)) + fun inlinePrompt(inlinePrompt: PromptData?) = inlinePrompt(JsonField.ofNullable(inlinePrompt)) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: Optional) = - inlinePrompt(inlinePrompt.getOrNull()) + fun inlinePrompt(inlinePrompt: Optional) = inlinePrompt(inlinePrompt.getOrNull()) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: JsonField) = apply { - this.inlinePrompt = inlinePrompt - } + fun inlinePrompt(inlinePrompt: JsonField) = + apply { + this.inlinePrompt = inlinePrompt + } /** The name of the inline prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -4375,44 +4660,53 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlinePrompt = InlinePrompt( - checkRequired("inlinePrompt", inlinePrompt), - name, - additionalProperties.toImmutable(), + checkRequired( + "inlinePrompt", inlinePrompt + ), + name, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4421,36 +4715,33 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" } } /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ @NoAutoDetect - class GitMetadataSettings - @JsonCreator - private constructor( - @JsonProperty("collect") - @ExcludeMissing - private val collect: JsonField = JsonMissing.of(), - @JsonProperty("fields") - @ExcludeMissing - private val fields: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class GitMetadataSettings @JsonCreator private constructor( + @JsonProperty("collect") @ExcludeMissing private val collect: JsonField = JsonMissing.of(), + @JsonProperty("fields") @ExcludeMissing private val fields: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun collect(): Collect = collect.getRequired("collect") fun fields(): Optional> = Optional.ofNullable(fields.getNullable("fields")) - @JsonProperty("collect") @ExcludeMissing fun _collect(): JsonField = collect + @JsonProperty("collect") + @ExcludeMissing + fun _collect(): JsonField = collect - @JsonProperty("fields") @ExcludeMissing fun _fields(): JsonField> = fields + @JsonProperty("fields") + @ExcludeMissing + fun _fields(): JsonField> = fields @JsonAnyGetter @ExcludeMissing @@ -4458,15 +4749,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GitMetadataSettings = apply { - if (validated) { - return@apply - } + fun validate(): GitMetadataSettings = + apply { + if (validated) { + return@apply + } - collect() - fields() - validated = true - } + collect() + fields() + validated = true + } fun toBuilder() = Builder().from(this) @@ -4476,11 +4768,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GitMetadataSettings]. * * The following fields are required: + * * ```java * .collect() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GitMetadataSettings]. */ @@ -4491,68 +4785,85 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(gitMetadataSettings: GitMetadataSettings) = apply { - collect = gitMetadataSettings.collect - fields = gitMetadataSettings.fields.map { it.toMutableList() } - additionalProperties = gitMetadataSettings.additionalProperties.toMutableMap() - } + internal fun from(gitMetadataSettings: GitMetadataSettings) = + apply { + collect = gitMetadataSettings.collect + fields = gitMetadataSettings.fields.map { it.toMutableList() } + additionalProperties = gitMetadataSettings.additionalProperties.toMutableMap() + } fun collect(collect: Collect) = collect(JsonField.of(collect)) - fun collect(collect: JsonField) = apply { this.collect = collect } + fun collect(collect: JsonField) = + apply { + this.collect = collect + } fun fields(fields: List) = fields(JsonField.of(fields)) - fun fields(fields: JsonField>) = apply { - this.fields = fields.map { it.toMutableList() } - } + fun fields(fields: JsonField>) = + apply { + this.fields = fields.map { it.toMutableList() } + } - fun addField(field: Field) = apply { - fields = - (fields ?: JsonField.of(mutableListOf())).also { + fun addField(field: Field) = + apply { + fields = (fields ?: JsonField.of(mutableListOf())).also { checkKnown("fields", it).add(field) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GitMetadataSettings = GitMetadataSettings( - checkRequired("collect", collect), - (fields ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "collect", collect + ), + (fields ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } - class Collect @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Collect @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -4576,18 +4887,18 @@ private constructor( * An enum containing [Collect]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Collect] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { ALL, NONE, SOME, - /** - * An enum member indicating that [Collect] was instantiated with an unknown value. - */ + /** An enum member indicating that [Collect] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4595,8 +4906,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -4613,7 +4924,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -4629,20 +4940,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Collect && value == other.value /* spotless:on */ + return /* spotless:off */ other is Collect && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4650,17 +4958,21 @@ private constructor( override fun toString() = value.toString() } - class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + class Field @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -4702,9 +5014,11 @@ private constructor( * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Field] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -4717,9 +5031,7 @@ private constructor( COMMIT_MESSAGE, COMMIT_TIME, GIT_DIFF, - /** - * An enum member indicating that [Field] was instantiated with an unknown value. - */ + /** An enum member indicating that [Field] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4727,8 +5039,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -4751,7 +5063,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -4773,20 +5085,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Field && value == other.value /* spotless:on */ + return /* spotless:off */ other is Field && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4795,11 +5104,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GitMetadataSettings && collect == other.collect && fields == other.fields && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GitMetadataSettings && collect == other.collect && fields == other.fields && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4808,20 +5117,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "GitMetadataSettings{collect=$collect, fields=$fields, additionalProperties=$additionalProperties}" + override fun toString() = "GitMetadataSettings{collect=$collect, fields=$fields, additionalProperties=$additionalProperties}" } /** - * Optional experiment-level metadata to store about the evaluation. You can later use this to - * slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -4830,20 +5136,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -4852,38 +5160,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4896,15 +5212,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EvalCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EvalCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EvalCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EvalCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 15cc8fb6..8fd15406 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -20,48 +20,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Experiment -@JsonCreator -private constructor( +class Experiment @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("public") - @ExcludeMissing - private val public_: JsonField = JsonMissing.of(), - @JsonProperty("base_exp_id") - @ExcludeMissing - private val baseExpId: JsonField = JsonMissing.of(), - @JsonProperty("commit") - @ExcludeMissing - private val commit: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_version") - @ExcludeMissing - private val datasetVersion: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") - @ExcludeMissing - private val repoInfo: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("public") @ExcludeMissing private val public_: JsonField = JsonMissing.of(), + @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing private val commit: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") @ExcludeMissing private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the experiment */ @@ -74,8 +49,8 @@ private constructor( fun projectId(): String = projectId.getRequired("project_id") /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Boolean = public_.getRequired("public") @@ -88,23 +63,23 @@ private constructor( /** Date of experiment creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = - Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the experiment */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -116,35 +91,54 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the experiment */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ + @JsonProperty("public") + @ExcludeMissing + fun _public_(): JsonField = public_ /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId + @JsonProperty("base_exp_id") + @ExcludeMissing + fun _baseExpId(): JsonField = baseExpId /** Commit, taken directly from `repo_info.commit` */ - @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + @JsonProperty("commit") + @ExcludeMissing + fun _commit(): JsonField = commit /** Date of experiment creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -156,16 +150,24 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the experiment */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") + @ExcludeMissing + fun _repoInfo(): JsonField = repoInfo /** Identifies the user who created the experiment */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -173,27 +175,28 @@ private constructor( private var validated: Boolean = false - fun validate(): Experiment = apply { - if (validated) { - return@apply - } + fun validate(): Experiment = + apply { + if (validated) { + return@apply + } - id() - name() - projectId() - public_() - baseExpId() - commit() - created() - datasetId() - datasetVersion() - deletedAt() - description() - metadata().ifPresent { it.validate() } - repoInfo().ifPresent { it.validate() } - userId() - validated = true - } + id() + name() + projectId() + public_() + baseExpId() + commit() + created() + datasetId() + datasetVersion() + deletedAt() + description() + metadata().ifPresent { it.validate() } + repoInfo().ifPresent { it.validate() } + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -203,6 +206,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Experiment]. * * The following fields are required: + * * ```java * .id() * .name() @@ -210,7 +214,8 @@ private constructor( * .public_() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Experiment]. */ @@ -233,53 +238,66 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experiment: Experiment) = apply { - id = experiment.id - name = experiment.name - projectId = experiment.projectId - public_ = experiment.public_ - baseExpId = experiment.baseExpId - commit = experiment.commit - created = experiment.created - datasetId = experiment.datasetId - datasetVersion = experiment.datasetVersion - deletedAt = experiment.deletedAt - description = experiment.description - metadata = experiment.metadata - repoInfo = experiment.repoInfo - userId = experiment.userId - additionalProperties = experiment.additionalProperties.toMutableMap() - } + internal fun from(experiment: Experiment) = + apply { + id = experiment.id + name = experiment.name + projectId = experiment.projectId + public_ = experiment.public_ + baseExpId = experiment.baseExpId + commit = experiment.commit + created = experiment.created + datasetId = experiment.datasetId + datasetVersion = experiment.datasetVersion + deletedAt = experiment.deletedAt + description = experiment.description + metadata = experiment.metadata + repoInfo = experiment.repoInfo + userId = experiment.userId + additionalProperties = experiment.additionalProperties.toMutableMap() + } /** Unique identifier for the experiment */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the experiment */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(JsonField.of(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { this.public_ = public_ } + fun public_(public_: JsonField) = + apply { + this.public_ = public_ + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) @@ -288,7 +306,10 @@ private constructor( fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: JsonField) = + apply { + this.baseExpId = baseExpId + } /** Commit, taken directly from `repo_info.commit` */ fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) @@ -297,7 +318,10 @@ private constructor( fun commit(commit: Optional) = commit(commit.getOrNull()) /** Commit, taken directly from `repo_info.commit` */ - fun commit(commit: JsonField) = apply { this.commit = commit } + fun commit(commit: JsonField) = + apply { + this.commit = commit + } /** Date of experiment creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -306,44 +330,52 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of experiment creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = - datasetVersion(JsonField.ofNullable(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + this.datasetVersion = datasetVersion + } /** Date of experiment deletion, or null if the experiment is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -352,7 +384,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -361,7 +396,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -370,7 +408,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -379,7 +420,10 @@ private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: JsonField) = + apply { + this.repoInfo = repoInfo + } /** Identifies the user who created the experiment */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -388,54 +432,70 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the experiment */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Experiment = Experiment( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("public_", public_), - baseExpId, - commit, - created, - datasetId, - datasetVersion, - deletedAt, - description, - metadata, - repoInfo, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "public_", public_ + ), + baseExpId, + commit, + created, + datasetId, + datasetVersion, + deletedAt, + description, + metadata, + repoInfo, + userId, + additionalProperties.toImmutable(), ) } /** User-controlled metadata about the experiment */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -444,20 +504,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -466,38 +528,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -510,11 +580,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Experiment && id == other.id && name == other.name && projectId == other.projectId && public_ == other.public_ && baseExpId == other.baseExpId && commit == other.commit && created == other.created && datasetId == other.datasetId && datasetVersion == other.datasetVersion && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && repoInfo == other.repoInfo && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && id == other.id && name == other.name && projectId == other.projectId && public_ == other.public_ && baseExpId == other.baseExpId && commit == other.commit && created == other.created && datasetId == other.datasetId && datasetVersion == other.datasetVersion && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && repoInfo == other.repoInfo && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -523,6 +593,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Experiment{id=$id, name=$name, projectId=$projectId, public_=$public_, baseExpId=$baseExpId, commit=$commit, created=$created, datasetId=$datasetId, datasetVersion=$datasetVersion, deletedAt=$deletedAt, description=$description, metadata=$metadata, repoInfo=$repoInfo, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Experiment{id=$id, name=$name, projectId=$projectId, public_=$public_, baseExpId=$baseExpId, commit=$commit, created=$created, datasetId=$datasetId, datasetVersion=$datasetVersion, deletedAt=$deletedAt, description=$description, metadata=$metadata, repoInfo=$repoInfo, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index ae017556..8a9b0ec5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new experiment. If there is an existing experiment in the project with the same name as - * the one specified in the request, will return the existing experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with + * the same name as the one specified in the request, will return the existing + * experiment unmodified */ -class ExperimentCreateParams -private constructor( +class ExperimentCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Unique identifier for the project that the experiment belongs under */ @@ -38,12 +39,15 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(): Optional = body.baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun datasetId(): Optional = body.datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ fun datasetVersion(): Optional = body.datasetVersion() @@ -51,9 +55,10 @@ private constructor( fun description(): Optional = body.description() /** - * Normally, creating an experiment with the same name as an existing experiment will return the - * existing one un-modified. But if `ensure_new` is true, registration will generate a new - * experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(): Optional = body.ensureNew() @@ -64,8 +69,8 @@ private constructor( fun name(): Optional = body.name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Optional = body.public_() @@ -78,12 +83,15 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun _baseExpId(): JsonField = body._baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun _datasetId(): JsonField = body._datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ fun _datasetVersion(): JsonField = body._datasetVersion() @@ -91,9 +99,10 @@ private constructor( fun _description(): JsonField = body._description() /** - * Normally, creating an experiment with the same name as an existing experiment will return the - * existing one un-modified. But if `ensure_new` is true, registration will generate a new - * experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun _ensureNew(): JsonField = body._ensureNew() @@ -104,8 +113,8 @@ private constructor( fun _name(): JsonField = body._name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun _public_(): JsonField = body._public_() @@ -118,80 +127,57 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("base_exp_id") - @ExcludeMissing - private val baseExpId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_version") - @ExcludeMissing - private val datasetVersion: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ensure_new") - @ExcludeMissing - private val ensureNew: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("public") - @ExcludeMissing - private val public_: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") - @ExcludeMissing - private val repoInfo: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") @ExcludeMissing private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("ensure_new") @ExcludeMissing private val ensureNew: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("public") @ExcludeMissing private val public_: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the project that the experiment belongs under */ fun projectId(): String = projectId.getRequired("project_id") /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(): Optional = - Optional.ofNullable(baseExpId.getNullable("base_exp_id")) + fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = - Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Textual description of the experiment */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - fun ensureNew(): Optional = - Optional.ofNullable(ensureNew.getNullable("ensure_new")) + fun ensureNew(): Optional = Optional.ofNullable(ensureNew.getNullable("ensure_new")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -200,8 +186,8 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) @@ -209,19 +195,26 @@ private constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId + @JsonProperty("base_exp_id") + @ExcludeMissing + fun _baseExpId(): JsonField = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -233,26 +226,37 @@ private constructor( fun _description(): JsonField = description /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - @JsonProperty("ensure_new") @ExcludeMissing fun _ensureNew(): JsonField = ensureNew + @JsonProperty("ensure_new") + @ExcludeMissing + fun _ensureNew(): JsonField = ensureNew /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ + @JsonProperty("public") + @ExcludeMissing + fun _public_(): JsonField = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") + @ExcludeMissing + fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @ExcludeMissing @@ -260,23 +264,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } - - projectId() - baseExpId() - datasetId() - datasetVersion() - description() - ensureNew() - metadata().ifPresent { it.validate() } - name() - public_() - repoInfo().ifPresent { it.validate() } - validated = true - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + projectId() + baseExpId() + datasetId() + datasetVersion() + description() + ensureNew() + metadata().ifPresent { it.validate() } + name() + public_() + repoInfo().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -286,11 +291,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -309,25 +316,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - projectId = body.projectId - baseExpId = body.baseExpId - datasetId = body.datasetId - datasetVersion = body.datasetVersion - description = body.description - ensureNew = body.ensureNew - metadata = body.metadata - name = body.name - public_ = body.public_ - repoInfo = body.repoInfo - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + projectId = body.projectId + baseExpId = body.baseExpId + datasetId = body.datasetId + datasetVersion = body.datasetVersion + description = body.description + ensureNew = body.ensureNew + metadata = body.metadata + name = body.name + public_ = body.public_ + repoInfo = body.repoInfo + additionalProperties = body.additionalProperties.toMutableMap() + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) @@ -336,7 +347,10 @@ private constructor( fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: JsonField) = + apply { + this.baseExpId = baseExpId + } /** * Identifier of the linked dataset, or null if the experiment is not linked to a @@ -354,29 +368,31 @@ private constructor( * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = - datasetVersion(JsonField.ofNullable(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + this.datasetVersion = datasetVersion + } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -385,37 +401,45 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Boolean?) = ensureNew(JsonField.ofNullable(ensureNew)) /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - fun ensureNew(ensureNew: JsonField) = apply { this.ensureNew = ensureNew } + fun ensureNew(ensureNew: JsonField) = + apply { + this.ensureNew = ensureNew + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -424,7 +448,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -433,31 +460,37 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { this.public_ = public_ } + fun public_(public_: JsonField) = + apply { + this.public_ = public_ + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -466,49 +499,61 @@ private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun repoInfo(repoInfo: JsonField) = + apply { + this.repoInfo = repoInfo + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("projectId", projectId), - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties.toImmutable(), + checkRequired( + "projectId", projectId + ), + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -517,8 +562,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = "Body{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -526,14 +570,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentCreateParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentCreateParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentCreateParams]. */ @@ -545,283 +592,380 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentCreateParams: ExperimentCreateParams) = apply { - body = experimentCreateParams.body.toBuilder() - additionalHeaders = experimentCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentCreateParams: ExperimentCreateParams) = + apply { + body = experimentCreateParams.body.toBuilder() + additionalHeaders = experimentCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentCreateParams.additionalQueryParams.toBuilder() + } /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } + fun baseExpId(baseExpId: String?) = + apply { + body.baseExpId(baseExpId) + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } + fun baseExpId(baseExpId: JsonField) = + apply { + body.baseExpId(baseExpId) + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + fun datasetId(datasetId: String?) = + apply { + body.datasetId(datasetId) + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } + fun datasetId(datasetId: JsonField) = + apply { + body.datasetId(datasetId) + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } + fun datasetVersion(datasetVersion: String?) = + apply { + body.datasetVersion(datasetVersion) + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - body.datasetVersion(datasetVersion) - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + body.datasetVersion(datasetVersion) + } /** Textual description of the experiment */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the experiment */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - fun ensureNew(ensureNew: Boolean?) = apply { body.ensureNew(ensureNew) } + fun ensureNew(ensureNew: Boolean?) = + apply { + body.ensureNew(ensureNew) + } /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - fun ensureNew(ensureNew: JsonField) = apply { body.ensureNew(ensureNew) } + fun ensureNew(ensureNew: JsonField) = + apply { + body.ensureNew(ensureNew) + } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: Boolean?) = apply { body.public_(public_) } + fun public_(public_: Boolean?) = + apply { + body.public_(public_) + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { body.public_(public_) } + fun public_(public_: JsonField) = + apply { + body.public_(public_) + } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: RepoInfo?) = + apply { + body.repoInfo(repoInfo) + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: JsonField) = + apply { + body.repoInfo(repoInfo) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentCreateParams = ExperimentCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the experiment */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -830,20 +974,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -852,38 +998,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -896,15 +1050,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index 6239af74..15fd2523 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an experiment object by its id */ -class ExperimentDeleteParams -private constructor( +class ExperimentDeleteParams private constructor( private val experimentId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Experiment id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentDeleteParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentDeleteParams: ExperimentDeleteParams) = apply { - experimentId = experimentDeleteParams.experimentId - additionalHeaders = experimentDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - experimentDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(experimentDeleteParams: ExperimentDeleteParams) = + apply { + experimentId = experimentDeleteParams.experimentId + additionalHeaders = experimentDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = experimentDeleteParams.additionalBodyProperties.toMutableMap() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ExperimentDeleteParams = ExperimentDeleteParams( - checkRequired("experimentId", experimentId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "experimentId", experimentId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentDeleteParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentDeleteParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index e49339eb..e764766b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -23,75 +23,43 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ExperimentEvent -@JsonCreator -private constructor( +class ExperimentEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("experiment_id") - @ExcludeMissing - private val experimentId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - private val context: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") - @ExcludeMissing - private val datasetRecordId: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("experiment_id") @ExcludeMissing private val experimentId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), + @JsonProperty("dataset_record_id") @ExcludeMissing private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("is_root") - @ExcludeMissing - private val isRoot: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") - @ExcludeMissing - private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the experiment (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the experiment (see the + * `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -108,63 +76,72 @@ private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different experiment events together as part of + * a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error + @JsonProperty("error") + @ExcludeMissing + fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** Whether this span is a root span */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) @@ -172,54 +149,63 @@ private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + @JsonProperty("output") + @ExcludeMissing + fun _output(): JsonValue = output /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the root - * span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the experiment (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the experiment (see the + * `version` parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Unique identifier for the experiment */ @JsonProperty("experiment_id") @@ -227,65 +213,86 @@ private constructor( fun _experimentId(): JsonField = experimentId /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** A unique identifier for the trace this experiment event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different experiment events together as part of + * a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId(): JsonField = datasetRecordId /** Whether this span is a root span */ - @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot + @JsonProperty("is_root") + @ExcludeMissing + fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -293,15 +300,18 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the root - * span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -309,30 +319,31 @@ private constructor( private var validated: Boolean = false - fun validate(): ExperimentEvent = apply { - if (validated) { - return@apply - } + fun validate(): ExperimentEvent = + apply { + if (validated) { + return@apply + } - id() - _xactId() - created() - experimentId() - projectId() - rootSpanId() - spanId() - context().ifPresent { it.validate() } - datasetRecordId() - isRoot() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanParents() - tags() - validated = true - } + id() + _xactId() + created() + experimentId() + projectId() + rootSpanId() + spanId() + context().ifPresent { it.validate() } + datasetRecordId() + isRoot() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -342,6 +353,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ExperimentEvent]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -352,7 +364,8 @@ private constructor( * .spanId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentEvent]. */ @@ -382,160 +395,200 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentEvent: ExperimentEvent) = apply { - id = experimentEvent.id - _xactId = experimentEvent._xactId - created = experimentEvent.created - experimentId = experimentEvent.experimentId - projectId = experimentEvent.projectId - rootSpanId = experimentEvent.rootSpanId - spanId = experimentEvent.spanId - context = experimentEvent.context - datasetRecordId = experimentEvent.datasetRecordId - error = experimentEvent.error - expected = experimentEvent.expected - input = experimentEvent.input - isRoot = experimentEvent.isRoot - metadata = experimentEvent.metadata - metrics = experimentEvent.metrics - origin = experimentEvent.origin - output = experimentEvent.output - scores = experimentEvent.scores - spanAttributes = experimentEvent.spanAttributes - spanParents = experimentEvent.spanParents.map { it.toMutableList() } - tags = experimentEvent.tags.map { it.toMutableList() } - additionalProperties = experimentEvent.additionalProperties.toMutableMap() - } + internal fun from(experimentEvent: ExperimentEvent) = + apply { + id = experimentEvent.id + _xactId = experimentEvent._xactId + created = experimentEvent.created + experimentId = experimentEvent.experimentId + projectId = experimentEvent.projectId + rootSpanId = experimentEvent.rootSpanId + spanId = experimentEvent.spanId + context = experimentEvent.context + datasetRecordId = experimentEvent.datasetRecordId + error = experimentEvent.error + expected = experimentEvent.expected + input = experimentEvent.input + isRoot = experimentEvent.isRoot + metadata = experimentEvent.metadata + metrics = experimentEvent.metrics + origin = experimentEvent.origin + output = experimentEvent.output + scores = experimentEvent.scores + spanAttributes = experimentEvent.spanAttributes + spanParents = experimentEvent.spanParents.map { it.toMutableList() } + tags = experimentEvent.tags.map { it.toMutableList() } + additionalProperties = experimentEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the experiment (see the + * `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the experiment (see the + * `version` parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the experiment event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Unique identifier for the experiment */ fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) /** Unique identifier for the experiment */ - fun experimentId(experimentId: JsonField) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: JsonField) = + apply { + this.experimentId = experimentId + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** A unique identifier for the trace this experiment event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** A unique identifier for the trace this experiment event belongs to */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different experiment events together as part of + * a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different experiment events together as part of + * a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = + apply { + this.context = context + } /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String?) = - datasetRecordId(JsonField.ofNullable(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String?) = datasetRecordId(JsonField.ofNullable(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.getOrNull()) + fun datasetRecordId(datasetRecordId: Optional) = datasetRecordId(datasetRecordId.getOrNull()) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } + fun datasetRecordId(datasetRecordId: JsonField) = + apply { + this.datasetRecordId = datasetRecordId + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = + apply { + this.error = error + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) @@ -547,55 +600,64 @@ private constructor( fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ - fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + fun isRoot(isRoot: JsonField) = + apply { + this.isRoot = isRoot + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** Indicates the event was copied from another object. */ fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) @@ -604,93 +666,109 @@ private constructor( fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = + apply { + this.output = output + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = - spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = + apply { + this.spanAttributes = spanAttributes + } /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -699,94 +777,109 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ExperimentEvent = ExperimentEvent( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("created", created), - checkRequired("experimentId", experimentId), - checkRequired("projectId", projectId), - checkRequired("rootSpanId", rootSpanId), - checkRequired("spanId", spanId), - context, - datasetRecordId, - error, - expected, - input, - isRoot, - metadata, - metrics, - origin, - output, - scores, - spanAttributes, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "created", created + ), + checkRequired( + "experimentId", experimentId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "rootSpanId", rootSpanId + ), + checkRequired( + "spanId", spanId + ), + context, + datasetRecordId, + error, + expected, + input, + isRoot, + metadata, + metrics, + origin, + output, + scores, + spanAttributes, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ @NoAutoDetect - class Context - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Context @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -809,23 +902,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Context = apply { - if (validated) { - return@apply - } + fun validate(): Context = + apply { + if (validated) { + return@apply + } - callerFilename() - callerFunctionname() - callerLineno() - validated = true - } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Context]. */ @@ -837,38 +932,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = + apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String?) = - callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = + apply { + this.callerFilename = callerFilename + } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String?) = - callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = + apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -880,44 +974,52 @@ private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = + apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -926,23 +1028,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -951,20 +1050,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -973,38 +1074,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1017,38 +1126,22 @@ private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - private val completionTokens: JsonField = JsonMissing.of(), + class Metrics @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") - @ExcludeMissing - private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") - @ExcludeMissing - private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** This metric is deprecated */ @@ -1062,31 +1155,31 @@ private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1094,35 +1187,41 @@ private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ - @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end + @JsonProperty("end") + @ExcludeMissing + fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ - @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + @JsonProperty("start") + @ExcludeMissing + fun _start(): JsonField = start /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1130,25 +1229,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true - } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1165,133 +1266,144 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = + apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = + apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = + apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun callerLineno(callerLineno: JsonValue) = + apply { + this.callerLineno = callerLineno + } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long?) = - completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long) = - completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = + apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ - fun end(end: JsonField) = apply { this.end = end } + fun end(end: JsonField) = + apply { + this.end = end + } /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = + apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = + apply { + this.start = start + } /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1303,47 +1415,57 @@ private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = + apply { + this.tokens = tokens + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1352,27 +1474,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** Indicates the event was copied from another object. */ @NoAutoDetect - class Origin - @JsonCreator - private constructor( + class Origin @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** ID of the original event. */ @@ -1388,13 +1501,19 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** Type of the object the event is originating from. */ @JsonProperty("object_type") @@ -1407,17 +1526,18 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - id() - _xactId() - objectId() - objectType() - validated = true - } + id() + _xactId() + objectId() + objectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1427,6 +1547,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -1434,7 +1555,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -1447,82 +1569,111 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() + } /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalProperties.toImmutable(), ) } /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1555,9 +1706,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1578,8 +1731,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1599,7 +1752,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1618,20 +1771,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1640,11 +1790,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1653,25 +1803,23 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1680,20 +1828,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1702,38 +1852,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1746,11 +1904,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1759,6 +1917,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index b4b3324a..4aba5528 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Log feedback for a set of experiment events */ -class ExperimentFeedbackParams -private constructor( +class ExperimentFeedbackParams private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("feedback") - @ExcludeMissing - private val feedback: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of experiment feedback items */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - feedback().forEach { it.validate() } - validated = true - } + feedback().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - feedback = body.feedback.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of experiment feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) /** A list of experiment feedback items */ - fun feedback(feedback: JsonField>) = apply { - this.feedback = feedback.map { it.toMutableList() } - } + fun feedback(feedback: JsonField>) = + apply { + this.feedback = feedback.map { it.toMutableList() } + } /** A list of experiment feedback items */ - fun addFeedback(feedback: FeedbackExperimentItem) = apply { - this.feedback = - (this.feedback ?: JsonField.of(mutableListOf())).also { + fun addFeedback(feedback: FeedbackExperimentItem) = + apply { + this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { checkKnown("feedback", it).add(feedback) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("feedback", feedback).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "feedback", feedback + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -174,8 +184,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -183,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentFeedbackParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentFeedbackParams]. * * The following fields are required: + * * ```java * .experimentId() * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentFeedbackParams]. */ @@ -204,163 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentFeedbackParams: ExperimentFeedbackParams) = apply { - experimentId = experimentFeedbackParams.experimentId - body = experimentFeedbackParams.body.toBuilder() - additionalHeaders = experimentFeedbackParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentFeedbackParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentFeedbackParams: ExperimentFeedbackParams) = + apply { + experimentId = experimentFeedbackParams.experimentId + body = experimentFeedbackParams.body.toBuilder() + additionalHeaders = experimentFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFeedbackParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** A list of experiment feedback items */ - fun feedback(feedback: List) = apply { body.feedback(feedback) } + fun feedback(feedback: List) = + apply { + body.feedback(feedback) + } /** A list of experiment feedback items */ - fun feedback(feedback: JsonField>) = apply { - body.feedback(feedback) - } + fun feedback(feedback: JsonField>) = + apply { + body.feedback(feedback) + } /** A list of experiment feedback items */ - fun addFeedback(feedback: FeedbackExperimentItem) = apply { body.addFeedback(feedback) } + fun addFeedback(feedback: FeedbackExperimentItem) = + apply { + body.addFeedback(feedback) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( - checkRequired("experimentId", experimentId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentFeedbackParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentFeedbackParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 53ca3670..611e5817 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -12,12 +12,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the POST form of the same path, + * but with the parameters in the URL query rather than in the request body. For + * more complex queries, use the `POST /btql` endpoint. */ -class ExperimentFetchParams -private constructor( +class ExperimentFetchParams private constructor( private val experimentId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -25,6 +24,7 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -33,52 +33,55 @@ private constructor( /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version) @@ -89,20 +92,36 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.maxRootSpanId?.let { + queryParams.put( + "max_root_span_id", listOf(it.toString()) + ) + } + this.maxXactId?.let { + queryParams.put( + "max_xact_id", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -110,14 +129,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentFetchParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentFetchParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentFetchParams]. */ @@ -133,263 +155,310 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentFetchParams: ExperimentFetchParams) = apply { - experimentId = experimentFetchParams.experimentId - limit = experimentFetchParams.limit - maxRootSpanId = experimentFetchParams.maxRootSpanId - maxXactId = experimentFetchParams.maxXactId - version = experimentFetchParams.version - additionalHeaders = experimentFetchParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentFetchParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentFetchParams: ExperimentFetchParams) = + apply { + experimentId = experimentFetchParams.experimentId + limit = experimentFetchParams.limit + maxRootSpanId = experimentFetchParams.maxRootSpanId + maxXactId = experimentFetchParams.maxXactId + version = experimentFetchParams.version + additionalHeaders = experimentFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFetchParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String?) = + apply { + this.maxXactId = maxXactId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentFetchParams = ExperimentFetchParams( - checkRequired("experimentId", experimentId), - limit, - maxRootSpanId, - maxXactId, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + limit, + maxRootSpanId, + maxXactId, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentFetchParams && experimentId == other.experimentId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchParams && experimentId == other.experimentId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index b6cde61b..a1838a8c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -22,138 +22,146 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ -class ExperimentFetchPostParams -private constructor( +class ExperimentFetchPostParams private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ fun experimentId(): String = experimentId /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = body.cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = body.limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = body.maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = body.maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun _cursor(): JsonField = body._cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxXactId(): JsonField = body._maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun _version(): JsonField = body._version() @@ -163,169 +171,168 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), - @JsonProperty("limit") - @ExcludeMissing - private val limit: JsonField = JsonMissing.of(), - @JsonProperty("max_root_span_id") - @ExcludeMissing - private val maxRootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("max_xact_id") - @ExcludeMissing - private val maxXactId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") @ExcludeMissing private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") @ExcludeMissing private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(): Optional = - Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(): Optional = - Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + @JsonProperty("limit") + @ExcludeMissing + fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId + @JsonProperty("max_xact_id") + @ExcludeMissing + fun _maxXactId(): JsonField = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -333,25 +340,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true } - cursor() - limit() - maxRootSpanId() - maxXactId() - version() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -365,261 +374,284 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - cursor = body.cursor - limit = body.limit - maxRootSpanId = body.maxRootSpanId - maxXactId = body.maxXactId - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { this.limit = limit } + fun limit(limit: JsonField) = + apply { + this.limit = limit + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: JsonField) = + apply { + this.maxXactId = maxXactId + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: String?) = version(JsonField.ofNullable(version)) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun version(version: JsonField) = + apply { + this.version = version + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toImmutable(), + cursor, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -628,8 +660,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -637,14 +668,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentFetchPostParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentFetchPostParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentFetchPostParams]. */ @@ -657,358 +691,431 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = apply { - experimentId = experimentFetchPostParams.experimentId - body = experimentFetchPostParams.body.toBuilder() - additionalHeaders = experimentFetchPostParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentFetchPostParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = + apply { + experimentId = experimentFetchPostParams.experimentId + body = experimentFetchPostParams.body.toBuilder() + additionalHeaders = experimentFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFetchPostParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: String?) = apply { body.cursor(cursor) } + fun cursor(cursor: String?) = + apply { + body.cursor(cursor) + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } + fun cursor(cursor: JsonField) = + apply { + body.cursor(cursor) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { body.limit(limit) } + fun limit(limit: Long?) = + apply { + body.limit(limit) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { body.limit(limit) } + fun limit(limit: JsonField) = + apply { + body.limit(limit) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: String?) = + apply { + body.maxXactId(maxXactId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: JsonField) = + apply { + body.maxXactId(maxXactId) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { body.version(version) } + fun version(version: String?) = + apply { + body.version(version) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { body.version(version) } + fun version(version: JsonField) = + apply { + body.version(version) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentFetchPostParams = ExperimentFetchPostParams( - checkRequired("experimentId", experimentId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentFetchPostParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentFetchPostParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index e04423cf..5dc9dc79 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Insert a set of events into the experiment */ -class ExperimentInsertParams -private constructor( +class ExperimentInsertParams private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of experiment events to insert */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - validated = true - } + events().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - events = body.events.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of experiment events to insert */ fun events(events: List) = events(JsonField.of(events)) /** A list of experiment events to insert */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of experiment events to insert */ - fun addEvent(event: InsertExperimentEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: InsertExperimentEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("events", events).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -182,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentInsertParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentInsertParams]. * * The following fields are required: + * * ```java * .experimentId() * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentInsertParams]. */ @@ -203,161 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentInsertParams: ExperimentInsertParams) = apply { - experimentId = experimentInsertParams.experimentId - body = experimentInsertParams.body.toBuilder() - additionalHeaders = experimentInsertParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentInsertParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentInsertParams: ExperimentInsertParams) = + apply { + experimentId = experimentInsertParams.experimentId + body = experimentInsertParams.body.toBuilder() + additionalHeaders = experimentInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentInsertParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** A list of experiment events to insert */ - fun events(events: List) = apply { body.events(events) } + fun events(events: List) = + apply { + body.events(events) + } /** A list of experiment events to insert */ - fun events(events: JsonField>) = apply { body.events(events) } + fun events(events: JsonField>) = + apply { + body.events(events) + } /** A list of experiment events to insert */ - fun addEvent(event: InsertExperimentEvent) = apply { body.addEvent(event) } + fun addEvent(event: InsertExperimentEvent) = + apply { + body.addEvent(event) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentInsertParams = ExperimentInsertParams( - checkRequired("experimentId", experimentId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentInsertParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentInsertParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 246697bc..78769b47 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.ExperimentService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ -class ExperimentListPage -private constructor( +class ExperimentListPage private constructor( private val experimentsService: ExperimentService, private val params: ExperimentListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentListPage && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ExperimentListPage && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ - override fun toString() = - "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" + override fun toString() = "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ExperimentListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ExperimentListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { experimentsService.list(it) } + return getNextPageParams().map { experimentsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - experimentsService: ExperimentService, - params: ExperimentListParams, - response: Response, - ) = ExperimentListPage(experimentsService, params, response) + fun of(experimentsService: ExperimentService, params: ExperimentListParams, response: Response) = + ExperimentListPage( + experimentsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ExperimentListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ExperimentListPage) : Iterable { + class AutoPager( + private val firstPage: ExperimentListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index a47c0c97..05812b0f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.ExperimentServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ -class ExperimentListPageAsync -private constructor( +class ExperimentListPageAsync private constructor( private val experimentsService: ExperimentServiceAsync, private val params: ExperimentListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentListPageAsync && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ExperimentListPageAsync && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ - override fun toString() = - "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" + override fun toString() = "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ExperimentListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ExperimentListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { experimentsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + experimentsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - experimentsService: ExperimentServiceAsync, - params: ExperimentListParams, - response: Response, - ) = ExperimentListPageAsync(experimentsService, params, response) + fun of(experimentsService: ExperimentServiceAsync, params: ExperimentListParams, response: Response) = + ExperimentListPageAsync( + experimentsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [ExperimentListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -151,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ExperimentListPageAsync) { + class AutoPager( + private val firstPage: ExperimentListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Experiment) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Experiment) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 2b4b05c0..e52715df 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ -class ExperimentListParams -private constructor( +class ExperimentListParams private constructor( private val endingBefore: String?, private val experimentName: String?, private val ids: Ids?, @@ -38,14 +37,15 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -53,8 +53,8 @@ private constructor( fun experimentName(): Optional = Optional.ofNullable(experimentName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -73,9 +73,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -86,27 +86,64 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.experimentName?.let { queryParams.put("experiment_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.experimentName?.let { + queryParams.put( + "experiment_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ExperimentListParams = builder().build() + @JvmStatic + fun none(): ExperimentListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [ExperimentListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ExperimentListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentListParams]. */ @@ -125,70 +162,82 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentListParams: ExperimentListParams) = apply { - endingBefore = experimentListParams.endingBefore - experimentName = experimentListParams.experimentName - ids = experimentListParams.ids - limit = experimentListParams.limit - orgName = experimentListParams.orgName - projectId = experimentListParams.projectId - projectName = experimentListParams.projectName - startingAfter = experimentListParams.startingAfter - additionalHeaders = experimentListParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentListParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentListParams: ExperimentListParams) = + apply { + endingBefore = experimentListParams.endingBefore + experimentName = experimentListParams.experimentName + ids = experimentListParams.ids + limit = experimentListParams.limit + orgName = experimentListParams.orgName + projectId = experimentListParams.projectId + projectName = experimentListParams.projectName + startingAfter = experimentListParams.startingAfter + additionalHeaders = experimentListParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the experiment to search for */ - fun experimentName(experimentName: String?) = apply { this.experimentName = experimentName } + fun experimentName(experimentName: String?) = + apply { + this.experimentName = experimentName + } /** Name of the experiment to search for */ - fun experimentName(experimentName: Optional) = - experimentName(experimentName.getOrNull()) + fun experimentName(experimentName: Optional) = experimentName(experimentName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -197,19 +246,28 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) @@ -217,146 +275,174 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentListParams = ExperimentListParams( - endingBefore, - experimentName, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + experimentName, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -374,19 +460,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -401,12 +487,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -416,60 +507,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentListParams && endingBefore == other.endingBefore && experimentName == other.experimentName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentListParams && endingBefore == other.endingBefore && experimentName == other.experimentName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index 042891d4..bf3d01fd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an experiment object by its id */ -class ExperimentRetrieveParams -private constructor( +class ExperimentRetrieveParams private constructor( private val experimentId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentRetrieveParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentRetrieveParams: ExperimentRetrieveParams) = apply { - experimentId = experimentRetrieveParams.experimentId - additionalHeaders = experimentRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentRetrieveParams: ExperimentRetrieveParams) = + apply { + experimentId = experimentRetrieveParams.experimentId + additionalHeaders = experimentRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentRetrieveParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( - checkRequired("experimentId", experimentId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentRetrieveParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentRetrieveParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index c988c73a..663d7cd0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -12,28 +12,29 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Summarize experiment */ -class ExperimentSummarizeParams -private constructor( +class ExperimentSummarizeParams private constructor( private val experimentId: String, private val comparisonExperimentId: String?, private val summarizeScores: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ fun experimentId(): String = experimentId /** - * The experiment to compare against, if summarizing scores and metrics. If omitted, will fall - * back to the `base_exp_id` stored in the experiment metadata, and then to the most recent - * experiment run in the same project. Must pass `summarize_scores=true` for this id to be used + * The experiment to compare against, if summarizing scores and metrics. If + * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, + * and then to the most recent experiment run in the same project. Must pass + * `summarize_scores=true` for this id to be used */ fun comparisonExperimentId(): Optional = Optional.ofNullable(comparisonExperimentId) /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata will be - * returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the + * metadata will be returned. */ fun summarizeScores(): Optional = Optional.ofNullable(summarizeScores) @@ -44,20 +45,26 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.comparisonExperimentId?.let { - queryParams.put("comparison_experiment_id", listOf(it.toString())) - } - this.summarizeScores?.let { queryParams.put("summarize_scores", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.comparisonExperimentId?.let { + queryParams.put( + "comparison_experiment_id", listOf(it.toString()) + ) + } + this.summarizeScores?.let { + queryParams.put( + "summarize_scores", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -65,14 +72,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentSummarizeParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentSummarizeParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentSummarizeParams]. */ @@ -86,175 +96,206 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentSummarizeParams: ExperimentSummarizeParams) = apply { - experimentId = experimentSummarizeParams.experimentId - comparisonExperimentId = experimentSummarizeParams.comparisonExperimentId - summarizeScores = experimentSummarizeParams.summarizeScores - additionalHeaders = experimentSummarizeParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentSummarizeParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentSummarizeParams: ExperimentSummarizeParams) = + apply { + experimentId = experimentSummarizeParams.experimentId + comparisonExperimentId = experimentSummarizeParams.comparisonExperimentId + summarizeScores = experimentSummarizeParams.summarizeScores + additionalHeaders = experimentSummarizeParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentSummarizeParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** - * The experiment to compare against, if summarizing scores and metrics. If omitted, will - * fall back to the `base_exp_id` stored in the experiment metadata, and then to the most - * recent experiment run in the same project. Must pass `summarize_scores=true` for this id - * to be used + * The experiment to compare against, if summarizing scores and metrics. If + * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, + * and then to the most recent experiment run in the same project. Must pass + * `summarize_scores=true` for this id to be used */ - fun comparisonExperimentId(comparisonExperimentId: String?) = apply { - this.comparisonExperimentId = comparisonExperimentId - } + fun comparisonExperimentId(comparisonExperimentId: String?) = + apply { + this.comparisonExperimentId = comparisonExperimentId + } /** - * The experiment to compare against, if summarizing scores and metrics. If omitted, will - * fall back to the `base_exp_id` stored in the experiment metadata, and then to the most - * recent experiment run in the same project. Must pass `summarize_scores=true` for this id - * to be used + * The experiment to compare against, if summarizing scores and metrics. If + * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, + * and then to the most recent experiment run in the same project. Must pass + * `summarize_scores=true` for this id to be used */ - fun comparisonExperimentId(comparisonExperimentId: Optional) = - comparisonExperimentId(comparisonExperimentId.getOrNull()) + fun comparisonExperimentId(comparisonExperimentId: Optional) = comparisonExperimentId(comparisonExperimentId.getOrNull()) /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata - * will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the + * metadata will be returned. */ - fun summarizeScores(summarizeScores: Boolean?) = apply { - this.summarizeScores = summarizeScores - } + fun summarizeScores(summarizeScores: Boolean?) = + apply { + this.summarizeScores = summarizeScores + } /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata - * will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the + * metadata will be returned. */ fun summarizeScores(summarizeScores: Boolean) = summarizeScores(summarizeScores as Boolean?) /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata - * will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the + * metadata will be returned. */ - fun summarizeScores(summarizeScores: Optional) = - summarizeScores(summarizeScores.getOrNull()) + fun summarizeScores(summarizeScores: Optional) = summarizeScores(summarizeScores.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentSummarizeParams = ExperimentSummarizeParams( - checkRequired("experimentId", experimentId), - comparisonExperimentId, - summarizeScores, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + comparisonExperimentId, + summarizeScores, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentSummarizeParams && experimentId == other.experimentId && comparisonExperimentId == other.comparisonExperimentId && summarizeScores == other.summarizeScores && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentSummarizeParams && experimentId == other.experimentId && comparisonExperimentId == other.comparisonExperimentId && summarizeScores == other.summarizeScores && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 1f99550c..eca783dd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class ExperimentUpdateParams -private constructor( +class ExperimentUpdateParams private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -40,12 +40,15 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(): Optional = body.baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun datasetId(): Optional = body.datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ fun datasetVersion(): Optional = body.datasetVersion() @@ -59,8 +62,8 @@ private constructor( fun name(): Optional = body.name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Optional = body.public_() @@ -70,12 +73,15 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun _baseExpId(): JsonField = body._baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun _datasetId(): JsonField = body._datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ fun _datasetVersion(): JsonField = body._datasetVersion() @@ -89,8 +95,8 @@ private constructor( fun _name(): JsonField = body._name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun _public_(): JsonField = body._public_() @@ -103,70 +109,51 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("base_exp_id") - @ExcludeMissing - private val baseExpId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_version") - @ExcludeMissing - private val datasetVersion: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("public") - @ExcludeMissing - private val public_: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") - @ExcludeMissing - private val repoInfo: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") @ExcludeMissing private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("public") @ExcludeMissing private val public_: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(): Optional = - Optional.ofNullable(baseExpId.getNullable("base_exp_id")) + fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = - Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Textual description of the experiment */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -175,8 +162,8 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) @@ -184,16 +171,21 @@ private constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId + @JsonProperty("base_exp_id") + @ExcludeMissing + fun _baseExpId(): JsonField = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -205,19 +197,27 @@ private constructor( fun _description(): JsonField = description /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ + @JsonProperty("public") + @ExcludeMissing + fun _public_(): JsonField = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") + @ExcludeMissing + fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @ExcludeMissing @@ -225,28 +225,30 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + baseExpId() + datasetId() + datasetVersion() + description() + metadata().ifPresent { it.validate() } + name() + public_() + repoInfo().ifPresent { it.validate() } + validated = true } - baseExpId() - datasetId() - datasetVersion() - description() - metadata().ifPresent { it.validate() } - name() - public_() - repoInfo().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -263,17 +265,18 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - baseExpId = body.baseExpId - datasetId = body.datasetId - datasetVersion = body.datasetVersion - description = body.description - metadata = body.metadata - name = body.name - public_ = body.public_ - repoInfo = body.repoInfo - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + baseExpId = body.baseExpId + datasetId = body.datasetId + datasetVersion = body.datasetVersion + description = body.description + metadata = body.metadata + name = body.name + public_ = body.public_ + repoInfo = body.repoInfo + additionalProperties = body.additionalProperties.toMutableMap() + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) @@ -282,7 +285,10 @@ private constructor( fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: JsonField) = + apply { + this.baseExpId = baseExpId + } /** * Identifier of the linked dataset, or null if the experiment is not linked to a @@ -300,29 +306,31 @@ private constructor( * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = - datasetVersion(JsonField.ofNullable(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + this.datasetVersion = datasetVersion + } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -331,9 +339,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -342,7 +351,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -351,31 +363,37 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { this.public_ = public_ } + fun public_(public_: JsonField) = + apply { + this.public_ = public_ + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -384,47 +402,57 @@ private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun repoInfo(repoInfo: JsonField) = + apply { + this.repoInfo = repoInfo + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalProperties.toImmutable(), + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -433,8 +461,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = "Body{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -442,14 +469,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentUpdateParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentUpdateParams]. */ @@ -462,254 +492,340 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentUpdateParams: ExperimentUpdateParams) = apply { - experimentId = experimentUpdateParams.experimentId - body = experimentUpdateParams.body.toBuilder() - additionalHeaders = experimentUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentUpdateParams: ExperimentUpdateParams) = + apply { + experimentId = experimentUpdateParams.experimentId + body = experimentUpdateParams.body.toBuilder() + additionalHeaders = experimentUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentUpdateParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } + fun baseExpId(baseExpId: String?) = + apply { + body.baseExpId(baseExpId) + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } + fun baseExpId(baseExpId: JsonField) = + apply { + body.baseExpId(baseExpId) + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + fun datasetId(datasetId: String?) = + apply { + body.datasetId(datasetId) + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } + fun datasetId(datasetId: JsonField) = + apply { + body.datasetId(datasetId) + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } + fun datasetVersion(datasetVersion: String?) = + apply { + body.datasetVersion(datasetVersion) + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - body.datasetVersion(datasetVersion) - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + body.datasetVersion(datasetVersion) + } /** Textual description of the experiment */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the experiment */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: Boolean?) = apply { body.public_(public_) } + fun public_(public_: Boolean?) = + apply { + body.public_(public_) + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { body.public_(public_) } + fun public_(public_: JsonField) = + apply { + body.public_(public_) + } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: RepoInfo?) = + apply { + body.repoInfo(repoInfo) + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: JsonField) = + apply { + body.repoInfo(repoInfo) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentUpdateParams = ExperimentUpdateParams( - checkRequired("experimentId", experimentId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the experiment */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -718,20 +834,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -740,38 +858,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -784,15 +910,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentUpdateParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentUpdateParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 887cdc58..1181a618 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -22,28 +22,19 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FeedbackDatasetItem -@JsonCreator -private constructor( +class FeedbackDatasetItem @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("comment") - @ExcludeMissing - private val comment: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("source") - @ExcludeMissing - private val source: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing private val comment: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned + * by `POST /v1/dataset/{dataset_id}/insert` */ fun id(): String = id.getRequired("id") @@ -51,9 +42,10 @@ private constructor( fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -64,26 +56,37 @@ private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned + * by `POST /v1/dataset/{dataset_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + @JsonProperty("comment") + @ExcludeMissing + fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + @JsonProperty("source") + @ExcludeMissing + fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -91,18 +94,19 @@ private constructor( private var validated: Boolean = false - fun validate(): FeedbackDatasetItem = apply { - if (validated) { - return@apply - } + fun validate(): FeedbackDatasetItem = + apply { + if (validated) { + return@apply + } - id() - comment() - metadata().ifPresent { it.validate() } - source() - tags() - validated = true - } + id() + comment() + metadata().ifPresent { it.validate() } + source() + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -112,11 +116,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [FeedbackDatasetItem]. * * The following fields are required: + * * ```java * .id() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FeedbackDatasetItem]. */ @@ -130,26 +136,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackDatasetItem: FeedbackDatasetItem) = apply { - id = feedbackDatasetItem.id - comment = feedbackDatasetItem.comment - metadata = feedbackDatasetItem.metadata - source = feedbackDatasetItem.source - tags = feedbackDatasetItem.tags.map { it.toMutableList() } - additionalProperties = feedbackDatasetItem.additionalProperties.toMutableMap() - } + internal fun from(feedbackDatasetItem: FeedbackDatasetItem) = + apply { + id = feedbackDatasetItem.id + comment = feedbackDatasetItem.comment + metadata = feedbackDatasetItem.metadata + source = feedbackDatasetItem.source + tags = feedbackDatasetItem.tags.map { it.toMutableList() } + additionalProperties = feedbackDatasetItem.additionalProperties.toMutableMap() + } /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned + * by `POST /v1/dataset/{dataset_id}/insert` */ fun id(id: String) = id(JsonField.of(id)) /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned + * by `POST /v1/dataset/{dataset_id}/insert` */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** An optional comment string to log about the dataset event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) @@ -158,28 +168,37 @@ private constructor( fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the dataset event */ - fun comment(comment: JsonField) = apply { this.comment = comment } + fun comment(comment: JsonField) = + apply { + this.comment = comment + } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) @@ -188,7 +207,10 @@ private constructor( fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: JsonField) = apply { this.source = source } + fun source(source: JsonField) = + apply { + this.source = source + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -197,56 +219,68 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackDatasetItem = FeedbackDatasetItem( - checkRequired("id", id), - comment, - metadata, - source, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + comment, + metadata, + source, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -255,20 +289,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -277,38 +313,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -321,17 +365,21 @@ private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source @JsonCreator private constructor(private val value: JsonField) : Enum { + class Source @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -355,9 +403,11 @@ private constructor( * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Source] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -369,11 +419,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -386,11 +436,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -403,23 +453,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -428,11 +475,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackDatasetItem && id == other.id && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackDatasetItem && id == other.id && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -441,6 +488,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index a30bbcd2..704af01b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -22,32 +22,21 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FeedbackExperimentItem -@JsonCreator -private constructor( +class FeedbackExperimentItem @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("comment") - @ExcludeMissing - private val comment: JsonField = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing private val comment: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("source") - @ExcludeMissing - private val source: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * The id of the experiment event to log feedback for. This is the row `id` returned by `POST - * /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` + * returned by `POST /v1/experiment/{experiment_id}/insert` */ fun id(): String = id.getRequired("id") @@ -55,21 +44,24 @@ private constructor( fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) @@ -80,32 +72,45 @@ private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the experiment event to log feedback for. This is the row `id` returned by `POST - * /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` + * returned by `POST /v1/experiment/{experiment_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + @JsonProperty("comment") + @ExcludeMissing + fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + @JsonProperty("source") + @ExcludeMissing + fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -113,33 +118,37 @@ private constructor( private var validated: Boolean = false - fun validate(): FeedbackExperimentItem = apply { - if (validated) { - return@apply - } + fun validate(): FeedbackExperimentItem = + apply { + if (validated) { + return@apply + } - id() - comment() - metadata().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - source() - tags() - validated = true - } + id() + comment() + metadata().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + source() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [FeedbackExperimentItem]. + * Returns a mutable builder for constructing an instance of + * [FeedbackExperimentItem]. * * The following fields are required: + * * ```java * .id() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FeedbackExperimentItem]. */ @@ -155,28 +164,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackExperimentItem: FeedbackExperimentItem) = apply { - id = feedbackExperimentItem.id - comment = feedbackExperimentItem.comment - expected = feedbackExperimentItem.expected - metadata = feedbackExperimentItem.metadata - scores = feedbackExperimentItem.scores - source = feedbackExperimentItem.source - tags = feedbackExperimentItem.tags.map { it.toMutableList() } - additionalProperties = feedbackExperimentItem.additionalProperties.toMutableMap() - } + internal fun from(feedbackExperimentItem: FeedbackExperimentItem) = + apply { + id = feedbackExperimentItem.id + comment = feedbackExperimentItem.comment + expected = feedbackExperimentItem.expected + metadata = feedbackExperimentItem.metadata + scores = feedbackExperimentItem.scores + source = feedbackExperimentItem.source + tags = feedbackExperimentItem.tags.map { it.toMutableList() } + additionalProperties = feedbackExperimentItem.additionalProperties.toMutableMap() + } /** - * The id of the experiment event to log feedback for. This is the row `id` returned by - * `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` + * returned by `POST /v1/experiment/{experiment_id}/insert` */ fun id(id: String) = id(JsonField.of(id)) /** - * The id of the experiment event to log feedback for. This is the row `id` returned by - * `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` + * returned by `POST /v1/experiment/{experiment_id}/insert` */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** An optional comment string to log about the experiment event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) @@ -185,52 +198,67 @@ private constructor( fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the experiment event */ - fun comment(comment: JsonField) = apply { this.comment = comment } + fun comment(comment: JsonField) = + apply { + this.comment = comment + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) @@ -239,7 +267,10 @@ private constructor( fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: JsonField) = apply { this.source = source } + fun source(source: JsonField) = + apply { + this.source = source + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -248,58 +279,70 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackExperimentItem = FeedbackExperimentItem( - checkRequired("id", id), - comment, - expected, - metadata, - scores, - source, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + comment, + expected, + metadata, + scores, + source, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -308,20 +351,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -330,38 +375,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -374,15 +427,13 @@ private constructor( } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -391,20 +442,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -413,38 +466,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -457,17 +518,21 @@ private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source @JsonCreator private constructor(private val value: JsonField) : Enum { + class Source @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -491,9 +556,11 @@ private constructor( * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Source] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -505,11 +572,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -522,11 +589,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -539,23 +606,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -564,11 +628,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackExperimentItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackExperimentItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -577,6 +641,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FeedbackExperimentItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackExperimentItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 14572b2f..e1e18a1d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -22,32 +22,21 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FeedbackProjectLogsItem -@JsonCreator -private constructor( +class FeedbackProjectLogsItem @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("comment") - @ExcludeMissing - private val comment: JsonField = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing private val comment: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("source") - @ExcludeMissing - private val source: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * The id of the project logs event to log feedback for. This is the row `id` returned by `POST - * /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` + * returned by `POST /v1/project_logs/{project_id}/insert` */ fun id(): String = id.getRequired("id") @@ -55,21 +44,24 @@ private constructor( fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) @@ -80,32 +72,45 @@ private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the project logs event to log feedback for. This is the row `id` returned by `POST - * /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` + * returned by `POST /v1/project_logs/{project_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + @JsonProperty("comment") + @ExcludeMissing + fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + @JsonProperty("source") + @ExcludeMissing + fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -113,33 +118,37 @@ private constructor( private var validated: Boolean = false - fun validate(): FeedbackProjectLogsItem = apply { - if (validated) { - return@apply - } + fun validate(): FeedbackProjectLogsItem = + apply { + if (validated) { + return@apply + } - id() - comment() - metadata().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - source() - tags() - validated = true - } + id() + comment() + metadata().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + source() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [FeedbackProjectLogsItem]. + * Returns a mutable builder for constructing an instance of + * [FeedbackProjectLogsItem]. * * The following fields are required: + * * ```java * .id() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FeedbackProjectLogsItem]. */ @@ -155,28 +164,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackProjectLogsItem: FeedbackProjectLogsItem) = apply { - id = feedbackProjectLogsItem.id - comment = feedbackProjectLogsItem.comment - expected = feedbackProjectLogsItem.expected - metadata = feedbackProjectLogsItem.metadata - scores = feedbackProjectLogsItem.scores - source = feedbackProjectLogsItem.source - tags = feedbackProjectLogsItem.tags.map { it.toMutableList() } - additionalProperties = feedbackProjectLogsItem.additionalProperties.toMutableMap() - } + internal fun from(feedbackProjectLogsItem: FeedbackProjectLogsItem) = + apply { + id = feedbackProjectLogsItem.id + comment = feedbackProjectLogsItem.comment + expected = feedbackProjectLogsItem.expected + metadata = feedbackProjectLogsItem.metadata + scores = feedbackProjectLogsItem.scores + source = feedbackProjectLogsItem.source + tags = feedbackProjectLogsItem.tags.map { it.toMutableList() } + additionalProperties = feedbackProjectLogsItem.additionalProperties.toMutableMap() + } /** - * The id of the project logs event to log feedback for. This is the row `id` returned by - * `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` + * returned by `POST /v1/project_logs/{project_id}/insert` */ fun id(id: String) = id(JsonField.of(id)) /** - * The id of the project logs event to log feedback for. This is the row `id` returned by - * `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` + * returned by `POST /v1/project_logs/{project_id}/insert` */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** An optional comment string to log about the project logs event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) @@ -185,52 +198,67 @@ private constructor( fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the project logs event */ - fun comment(comment: JsonField) = apply { this.comment = comment } + fun comment(comment: JsonField) = + apply { + this.comment = comment + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) @@ -239,7 +267,10 @@ private constructor( fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: JsonField) = apply { this.source = source } + fun source(source: JsonField) = + apply { + this.source = source + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -248,58 +279,70 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackProjectLogsItem = FeedbackProjectLogsItem( - checkRequired("id", id), - comment, - expected, - metadata, - scores, - source, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + comment, + expected, + metadata, + scores, + source, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -308,20 +351,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -330,38 +375,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -374,15 +427,13 @@ private constructor( } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -391,20 +442,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -413,38 +466,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -457,17 +518,21 @@ private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source @JsonCreator private constructor(private val value: JsonField) : Enum { + class Source @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -491,9 +556,11 @@ private constructor( * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Source] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -505,11 +572,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -522,11 +589,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -539,23 +606,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -564,11 +628,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackProjectLogsItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackProjectLogsItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -577,6 +641,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FeedbackProjectLogsItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackProjectLogsItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index d4e37e96..fe72645f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -19,18 +19,17 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class FeedbackResponseSchema -@JsonCreator -private constructor( - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), +class FeedbackResponseSchema @JsonCreator private constructor( + @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun status(): Status = status.getRequired("status") - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -38,28 +37,32 @@ private constructor( private var validated: Boolean = false - fun validate(): FeedbackResponseSchema = apply { - if (validated) { - return@apply - } + fun validate(): FeedbackResponseSchema = + apply { + if (validated) { + return@apply + } - status() - validated = true - } + status() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [FeedbackResponseSchema]. + * Returns a mutable builder for constructing an instance of + * [FeedbackResponseSchema]. * * The following fields are required: + * * ```java * .status() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FeedbackResponseSchema]. */ @@ -69,52 +72,68 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackResponseSchema: FeedbackResponseSchema) = apply { - status = feedbackResponseSchema.status - additionalProperties = feedbackResponseSchema.additionalProperties.toMutableMap() - } + internal fun from(feedbackResponseSchema: FeedbackResponseSchema) = + apply { + status = feedbackResponseSchema.status + additionalProperties = feedbackResponseSchema.additionalProperties.toMutableMap() + } fun status(status: Status) = status(JsonField.of(status)) - fun status(status: JsonField) = apply { this.status = status } + fun status(status: JsonField) = + apply { + this.status = status + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackResponseSchema = FeedbackResponseSchema( - checkRequired("status", status), - additionalProperties.toImmutable(), + checkRequired( + "status", status + ), additionalProperties.toImmutable() ) } - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + class Status @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -125,16 +144,18 @@ private constructor( /** An enum containing [Status]'s known values. */ enum class Known { - SUCCESS + SUCCESS, } /** * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -144,11 +165,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -159,11 +180,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -174,23 +195,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -199,11 +217,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackResponseSchema && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackResponseSchema && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -212,6 +230,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index 93503c6a..4dac3d22 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -20,16 +20,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FetchDatasetEventsResponse -@JsonCreator -private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), +class FetchDatasetEventsResponse @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of fetched events */ @@ -38,21 +33,25 @@ private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing @@ -60,29 +59,33 @@ private constructor( private var validated: Boolean = false - fun validate(): FetchDatasetEventsResponse = apply { - if (validated) { - return@apply - } + fun validate(): FetchDatasetEventsResponse = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - cursor() - validated = true - } + events().forEach { it.validate() } + cursor() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [FetchDatasetEventsResponse]. + * Returns a mutable builder for constructing an instance of + * [FetchDatasetEventsResponse]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FetchDatasetEventsResponse]. */ @@ -93,85 +96,99 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fetchDatasetEventsResponse: FetchDatasetEventsResponse) = apply { - events = fetchDatasetEventsResponse.events.map { it.toMutableList() } - cursor = fetchDatasetEventsResponse.cursor - additionalProperties = fetchDatasetEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(fetchDatasetEventsResponse: FetchDatasetEventsResponse) = + apply { + events = fetchDatasetEventsResponse.events.map { it.toMutableList() } + cursor = fetchDatasetEventsResponse.cursor + additionalProperties = fetchDatasetEventsResponse.additionalProperties.toMutableMap() + } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of fetched events */ - fun addEvent(event: DatasetEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: DatasetEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } + } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FetchDatasetEventsResponse = FetchDatasetEventsResponse( - checkRequired("events", events).map { it.toImmutable() }, - cursor, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, + cursor, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FetchDatasetEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchDatasetEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -180,6 +197,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 23656816..79cd0295 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -20,16 +20,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FetchExperimentEventsResponse -@JsonCreator -private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), +class FetchExperimentEventsResponse @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of fetched events */ @@ -38,21 +33,25 @@ private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing @@ -60,15 +59,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FetchExperimentEventsResponse = apply { - if (validated) { - return@apply - } + fun validate(): FetchExperimentEventsResponse = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - cursor() - validated = true - } + events().forEach { it.validate() } + cursor() + validated = true + } fun toBuilder() = Builder().from(this) @@ -79,11 +79,13 @@ private constructor( * [FetchExperimentEventsResponse]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FetchExperimentEventsResponse]. */ @@ -94,85 +96,99 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fetchExperimentEventsResponse: FetchExperimentEventsResponse) = apply { - events = fetchExperimentEventsResponse.events.map { it.toMutableList() } - cursor = fetchExperimentEventsResponse.cursor - additionalProperties = fetchExperimentEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(fetchExperimentEventsResponse: FetchExperimentEventsResponse) = + apply { + events = fetchExperimentEventsResponse.events.map { it.toMutableList() } + cursor = fetchExperimentEventsResponse.cursor + additionalProperties = fetchExperimentEventsResponse.additionalProperties.toMutableMap() + } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of fetched events */ - fun addEvent(event: ExperimentEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: ExperimentEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } + } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FetchExperimentEventsResponse = FetchExperimentEventsResponse( - checkRequired("events", events).map { it.toImmutable() }, - cursor, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, + cursor, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FetchExperimentEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchExperimentEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -181,6 +197,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index 1fd8d53c..09df951f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -20,16 +20,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FetchProjectLogsEventsResponse -@JsonCreator -private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), +class FetchProjectLogsEventsResponse @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of fetched events */ @@ -38,8 +33,8 @@ private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) @@ -51,10 +46,12 @@ private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing @@ -62,15 +59,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FetchProjectLogsEventsResponse = apply { - if (validated) { - return@apply - } + fun validate(): FetchProjectLogsEventsResponse = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - cursor() - validated = true - } + events().forEach { it.validate() } + cursor() + validated = true + } fun toBuilder() = Builder().from(this) @@ -81,11 +79,13 @@ private constructor( * [FetchProjectLogsEventsResponse]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FetchProjectLogsEventsResponse]. */ @@ -96,86 +96,99 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fetchProjectLogsEventsResponse: FetchProjectLogsEventsResponse) = apply { - events = fetchProjectLogsEventsResponse.events.map { it.toMutableList() } - cursor = fetchProjectLogsEventsResponse.cursor - additionalProperties = - fetchProjectLogsEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(fetchProjectLogsEventsResponse: FetchProjectLogsEventsResponse) = + apply { + events = fetchProjectLogsEventsResponse.events.map { it.toMutableList() } + cursor = fetchProjectLogsEventsResponse.cursor + additionalProperties = fetchProjectLogsEventsResponse.additionalProperties.toMutableMap() + } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of fetched events */ - fun addEvent(event: ProjectLogsEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: ProjectLogsEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } + } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse( - checkRequired("events", events).map { it.toImmutable() }, - cursor, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, + cursor, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FetchProjectLogsEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchProjectLogsEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -184,6 +197,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt index 57056d70..34c094de 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt @@ -33,57 +33,35 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Function -@JsonCreator -private constructor( +class Function @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("function_data") - @ExcludeMissing - private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_schema") - @ExcludeMissing - private val functionSchema: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") @ExcludeMissing private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -108,15 +86,12 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = - Optional.ofNullable(functionSchema.getNullable("function_schema")) + fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) /** User-controlled metadata about the prompt */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -124,46 +99,64 @@ private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId @JsonProperty("function_data") @ExcludeMissing fun _functionData(): JsonField = functionData /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId + @JsonProperty("log_id") + @ExcludeMissing + fun _logId(): JsonField = logId /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** JSON schema for the function's parameters and return type */ @JsonProperty("function_schema") @@ -175,9 +168,13 @@ private constructor( fun _functionType(): JsonField = functionType /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -185,7 +182,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -193,29 +192,30 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - id() - _xactId() - functionData().validate() - logId() - name() - orgId() - projectId() - slug() - created() - description() - functionSchema().ifPresent { it.validate() } - functionType() - metadata().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + id() + _xactId() + functionData().validate() + logId() + name() + orgId() + projectId() + slug() + created() + description() + functionSchema().ifPresent { it.validate() } + functionType() + metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -225,6 +225,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -236,7 +237,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -261,51 +263,61 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - id = function.id - _xactId = function._xactId - functionData = function.functionData - logId = function.logId - name = function.name - orgId = function.orgId - projectId = function.projectId - slug = function.slug - created = function.created - description = function.description - functionSchema = function.functionSchema - functionType = function.functionType - metadata = function.metadata - origin = function.origin - promptData = function.promptData - tags = function.tags.map { it.toMutableList() } - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + id = function.id + _xactId = function._xactId + functionData = function.functionData + logId = function.logId + name = function.name + orgId = function.orgId + projectId = function.projectId + slug = function.slug + created = function.created + description = function.description + functionSchema = function.functionSchema + functionType = function.functionType + metadata = function.metadata + origin = function.origin + promptData = function.promptData + tags = function.tags.map { it.toMutableList() } + additionalProperties = function.additionalProperties.toMutableMap() + } /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = + apply { + this.functionData = functionData + } fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) @@ -317,31 +329,46 @@ private constructor( fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: JsonField) = apply { this.logId = logId } + fun logId(logId: JsonField) = + apply { + this.logId = logId + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Date of prompt creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -350,7 +377,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of prompt creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -359,30 +389,31 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = - functionSchema(JsonField.ofNullable(functionSchema)) + fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - this.functionSchema = functionSchema - } + fun functionSchema(functionSchema: JsonField) = + apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -391,13 +422,19 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the prompt */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -406,7 +443,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -415,64 +455,91 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("functionData", functionData), - checkRequired("logId", logId), - checkRequired("name", name), - checkRequired("orgId", orgId), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - created, - description, - functionSchema, - functionType, - metadata, - origin, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "functionData", functionData + ), + checkRequired( + "logId", logId + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + created, + description, + functionSchema, + functionType, + metadata, + origin, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( + class FunctionData private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -496,45 +563,44 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ @@ -550,16 +616,19 @@ private constructor( companion object { - @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic + fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic + fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic + fun ofGlobal(global: Global) = FunctionData(global = global) } /** - * An interface that defines how to map each variant of [FunctionData] to a value of type - * [T]. + * An interface that defines how to map each variant of [FunctionData] to a value + * of type [T]. */ interface Visitor { @@ -572,71 +641,62 @@ private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(global = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize( - value: FunctionData, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Prompt @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -644,14 +704,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -661,11 +722,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -675,43 +738,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt(checkRequired("type", type), additionalProperties.toImmutable()) + Prompt( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -721,7 +798,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -732,23 +810,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT + PROMPT, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { PROMPT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -772,7 +850,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -787,19 +865,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -808,11 +883,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -821,31 +896,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code - @JsonCreator - private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Code @JsonCreator private constructor( + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -853,15 +925,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Code = apply { - if (validated) { - return@apply - } + fun validate(): Code = + apply { + if (validated) { + return@apply + } - data().validate() - type() - validated = true - } + data().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -871,12 +944,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: + * * ```java * .data() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Code]. */ @@ -887,15 +962,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = + apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -903,45 +982,56 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired("data", data), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, + ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -959,40 +1049,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() + inline.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1007,9 +1096,11 @@ private constructor( companion object { - @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic + fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic + fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1025,86 +1116,65 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle - @JsonCreator - private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = - JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Bundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = - Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1125,7 +1195,9 @@ private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1141,18 +1213,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Bundle = apply { - if (validated) { - return@apply - } + fun validate(): Bundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1162,6 +1235,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() @@ -1169,7 +1243,8 @@ private constructor( * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1180,40 +1255,38 @@ private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = + apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = - location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = + apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = - location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = - location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1227,11 +1300,17 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1239,44 +1318,57 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1290,25 +1382,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE + BUNDLE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { BUNDLE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1316,8 +1406,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1328,11 +1418,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1343,23 +1433,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1368,11 +1455,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1381,41 +1468,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Inline @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1423,16 +1504,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Inline = apply { - if (validated) { - return@apply - } + fun validate(): Inline = + apply { + if (validated) { + return@apply + } - code() - runtimeContext().validate() - type() - validated = true - } + code() + runtimeContext().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1442,13 +1524,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: + * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1457,31 +1541,37 @@ private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = + apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1489,44 +1579,47 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired("code", code), - checkRequired("runtimeContext", runtimeContext), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "runtimeContext", runtimeContext + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1547,31 +1640,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [RuntimeContext]. + * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1579,28 +1674,29 @@ private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = - runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = + apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1608,41 +1704,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1663,33 +1768,29 @@ private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] can contain an unknown value in a couple of cases: + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. * - * An instance of [Runtime] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1701,42 +1802,36 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value - * is a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") } /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1745,11 +1840,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1758,21 +1853,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1786,25 +1881,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE + INLINE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { INLINE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1812,8 +1905,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1824,11 +1917,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1839,23 +1932,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1864,11 +1954,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1877,13 +1967,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1893,7 +1984,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1904,23 +1996,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE + CODE, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { CODE, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1944,7 +2036,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1959,19 +2051,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1980,11 +2069,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1993,31 +2082,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2025,15 +2111,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2043,12 +2130,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -2059,52 +2148,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2114,7 +2220,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2125,23 +2232,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2165,7 +2272,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2180,19 +2287,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2201,11 +2305,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2214,23 +2318,26 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** A literal 'p' which identifies the object as a project prompt */ - class LogId @JsonCreator private constructor(private val value: JsonField) : Enum { + class LogId @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2241,16 +2348,18 @@ private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - P + P, } /** * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LogId] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2260,11 +2369,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2275,11 +2384,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2290,23 +2399,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2316,20 +2422,20 @@ private constructor( /** JSON schema for the function's parameters and return type */ @NoAutoDetect - class FunctionSchema - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - private val parameters: JsonValue = JsonMissing.of(), + class FunctionSchema @JsonCreator private constructor( + @JsonProperty("parameters") @ExcludeMissing private val parameters: JsonValue = JsonMissing.of(), @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonValue = parameters - @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns + @JsonProperty("returns") + @ExcludeMissing + fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing @@ -2337,20 +2443,22 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionSchema = apply { - if (validated) { - return@apply - } + fun validate(): FunctionSchema = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionSchema]. */ @@ -2361,45 +2469,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionSchema: FunctionSchema) = apply { - parameters = functionSchema.parameters - returns = functionSchema.returns - additionalProperties = functionSchema.additionalProperties.toMutableMap() - } + internal fun from(functionSchema: FunctionSchema) = + apply { + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() + } - fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } + fun parameters(parameters: JsonValue) = + apply { + this.parameters = parameters + } - fun returns(returns: JsonValue) = apply { this.returns = returns } + fun returns(returns: JsonValue) = + apply { + this.returns = returns + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionSchema = - FunctionSchema(parameters, returns, additionalProperties.toImmutable()) + FunctionSchema( + parameters, + returns, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2408,22 +2534,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2447,12 +2575,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2461,17 +2592,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2485,11 +2617,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2503,23 +2635,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2529,11 +2658,9 @@ private constructor( /** User-controlled metadata about the prompt */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -2542,20 +2669,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -2564,38 +2693,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2608,20 +2745,12 @@ private constructor( } @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("internal") - @ExcludeMissing - private val internal_: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Origin @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Id of the object the function is originating from */ @@ -2631,13 +2760,15 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -2645,10 +2776,12 @@ private constructor( fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ + @JsonProperty("internal") + @ExcludeMissing + fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing @@ -2656,16 +2789,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - internal_() - validated = true - } + objectId() + objectType() + internal_() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2675,12 +2809,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -2692,92 +2828,114 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - objectId = origin.objectId - objectType = origin.objectType - internal_ = origin.internal_ - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() + } /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } + fun internal_(internal_: JsonField) = + apply { + this.internal_ = internal_ + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - internal_, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + internal_, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2825,9 +2983,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2853,8 +3013,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2879,7 +3039,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2903,20 +3063,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2925,11 +3082,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2938,16 +3095,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && id == other.id && _xactId == other._xactId && functionData == other.functionData && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && metadata == other.metadata && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && _xactId == other._xactId && functionData == other.functionData && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && metadata == other.metadata && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2956,6 +3112,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{id=$id, _xactId=$_xactId, functionData=$functionData, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionSchema=$functionSchema, functionType=$functionType, metadata=$metadata, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Function{id=$id, _xactId=$_xactId, functionData=$functionData, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionSchema=$functionSchema, functionType=$functionType, metadata=$metadata, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt index e5ea58a3..391164d2 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,14 +35,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new function. If there is an existing function in the project with the same slug as the - * one specified in the request, will return the existing function unmodified + * Create a new function. If there is an existing function in the project with the + * same slug as the one specified in the request, will return the existing function + * unmodified */ -class FunctionCreateParams -private constructor( +class FunctionCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { fun functionData(): FunctionData = body.functionData() @@ -105,48 +106,27 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("function_data") - @ExcludeMissing - private val functionData: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_schema") - @ExcludeMissing - private val functionSchema: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") @ExcludeMissing private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun functionData(): FunctionData = functionData.getRequired("function_data") @@ -161,21 +141,17 @@ private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = - Optional.ofNullable(functionSchema.getNullable("function_schema")) + fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -185,13 +161,19 @@ private constructor( fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -207,7 +189,9 @@ private constructor( @ExcludeMissing fun _functionType(): JsonField = functionType - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -215,7 +199,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -223,23 +209,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } - - functionData().validate() - name() - projectId() - slug() - description() - functionSchema().ifPresent { it.validate() } - functionType() - origin().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + functionData().validate() + name() + projectId() + slug() + description() + functionSchema().ifPresent { it.validate() } + functionType() + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -249,6 +236,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .functionData() * .name() @@ -256,7 +244,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -275,51 +264,60 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - functionData = body.functionData - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionSchema = body.functionSchema - functionType = body.functionType - origin = body.origin - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + functionData = body.functionData + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionSchema = body.functionSchema + functionType = body.functionType + origin = body.origin + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = + apply { + this.functionData = functionData + } - fun functionData(prompt: FunctionData.Prompt) = - functionData(FunctionData.ofPrompt(prompt)) + fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) - fun functionData(global: FunctionData.Global) = - functionData(FunctionData.ofGlobal(global)) + fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -328,38 +326,40 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = - functionSchema(JsonField.ofNullable(functionSchema)) + fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - this.functionSchema = functionSchema - } + fun functionSchema(functionSchema: JsonField) = + apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -368,9 +368,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -379,57 +380,75 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("functionData", functionData), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - description, - functionSchema, - functionType, - origin, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "functionData", functionData + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + description, + functionSchema, + functionType, + origin, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -438,8 +457,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -447,9 +465,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionCreateParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionCreateParams]. * * The following fields are required: + * * ```java * .functionData() * .name() @@ -457,7 +477,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionCreateParams]. */ @@ -469,234 +490,331 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionCreateParams: FunctionCreateParams) = apply { - body = functionCreateParams.body.toBuilder() - additionalHeaders = functionCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = functionCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(functionCreateParams: FunctionCreateParams) = + apply { + body = functionCreateParams.body.toBuilder() + additionalHeaders = functionCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = functionCreateParams.additionalQueryParams.toBuilder() + } - fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + fun functionData(functionData: FunctionData) = + apply { + body.functionData(functionData) + } - fun functionData(functionData: JsonField) = apply { - body.functionData(functionData) - } + fun functionData(functionData: JsonField) = + apply { + body.functionData(functionData) + } - fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + fun functionData(prompt: FunctionData.Prompt) = + apply { + body.functionData(prompt) + } - fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + fun functionData(code: FunctionData.Code) = + apply { + body.functionData(code) + } - fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } + fun functionData(global: FunctionData.Global) = + apply { + body.functionData(global) + } /** Name of the prompt */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { body.slug(slug) } + fun slug(slug: String) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: FunctionSchema?) = + apply { + body.functionSchema(functionSchema) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: JsonField) = + apply { + body.functionSchema(functionSchema) + } - fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + fun functionType(functionType: FunctionType?) = + apply { + body.functionType(functionType) + } - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = + apply { + body.functionType(functionType) + } - fun origin(origin: Origin?) = apply { body.origin(origin) } + fun origin(origin: Origin?) = + apply { + body.origin(origin) + } fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { body.origin(origin) } + fun origin(origin: JsonField) = + apply { + body.origin(origin) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionCreateParams = FunctionCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( + class FunctionData private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -720,45 +838,44 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ @@ -774,16 +891,19 @@ private constructor( companion object { - @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic + fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic + fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic + fun ofGlobal(global: Global) = FunctionData(global = global) } /** - * An interface that defines how to map each variant of [FunctionData] to a value of type - * [T]. + * An interface that defines how to map each variant of [FunctionData] to a value + * of type [T]. */ interface Visitor { @@ -796,71 +916,62 @@ private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(global = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize( - value: FunctionData, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Prompt @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -868,14 +979,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -885,11 +997,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -899,43 +1013,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt(checkRequired("type", type), additionalProperties.toImmutable()) + Prompt( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -945,7 +1073,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -956,23 +1085,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT + PROMPT, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { PROMPT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -996,7 +1125,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1011,19 +1140,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1032,11 +1158,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1045,31 +1171,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code - @JsonCreator - private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Code @JsonCreator private constructor( + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1077,15 +1200,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Code = apply { - if (validated) { - return@apply - } + fun validate(): Code = + apply { + if (validated) { + return@apply + } - data().validate() - type() - validated = true - } + data().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1095,12 +1219,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: + * * ```java * .data() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Code]. */ @@ -1111,15 +1237,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = + apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -1127,45 +1257,56 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired("data", data), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, + ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1183,40 +1324,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() + inline.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1231,9 +1371,11 @@ private constructor( companion object { - @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic + fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic + fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1249,86 +1391,65 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle - @JsonCreator - private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = - JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Bundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = - Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1349,7 +1470,9 @@ private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1365,18 +1488,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Bundle = apply { - if (validated) { - return@apply - } + fun validate(): Bundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1386,6 +1510,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() @@ -1393,7 +1518,8 @@ private constructor( * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1404,40 +1530,38 @@ private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = + apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = - location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = + apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = - location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = - location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1451,11 +1575,17 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1463,44 +1593,57 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1514,25 +1657,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE + BUNDLE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { BUNDLE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1540,8 +1681,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1552,11 +1693,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1567,23 +1708,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1592,11 +1730,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1605,41 +1743,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Inline @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1647,16 +1779,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Inline = apply { - if (validated) { - return@apply - } + fun validate(): Inline = + apply { + if (validated) { + return@apply + } - code() - runtimeContext().validate() - type() - validated = true - } + code() + runtimeContext().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1666,13 +1799,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: + * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1681,31 +1816,37 @@ private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = + apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1713,44 +1854,47 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired("code", code), - checkRequired("runtimeContext", runtimeContext), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "runtimeContext", runtimeContext + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1771,31 +1915,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [RuntimeContext]. + * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1803,28 +1949,29 @@ private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = - runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = + apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1832,41 +1979,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1887,33 +2043,29 @@ private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] can contain an unknown value in a couple of cases: + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. * - * An instance of [Runtime] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1925,42 +2077,36 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value - * is a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") } /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1969,11 +2115,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1982,21 +2128,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -2010,25 +2156,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE + INLINE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { INLINE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2036,8 +2180,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2048,11 +2192,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2063,23 +2207,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2088,11 +2229,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2101,13 +2242,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2117,7 +2259,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2128,23 +2271,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE + CODE, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { CODE, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2168,7 +2311,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2183,19 +2326,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2204,11 +2344,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2217,31 +2357,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2249,15 +2386,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2267,12 +2405,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -2283,52 +2423,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2338,7 +2495,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2349,23 +2507,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2389,7 +2547,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2404,19 +2562,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2425,11 +2580,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2438,27 +2593,26 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** JSON schema for the function's parameters and return type */ @NoAutoDetect - class FunctionSchema - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - private val parameters: JsonValue = JsonMissing.of(), + class FunctionSchema @JsonCreator private constructor( + @JsonProperty("parameters") @ExcludeMissing private val parameters: JsonValue = JsonMissing.of(), @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonValue = parameters - @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns + @JsonProperty("returns") + @ExcludeMissing + fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing @@ -2466,20 +2620,22 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionSchema = apply { - if (validated) { - return@apply - } + fun validate(): FunctionSchema = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionSchema]. */ @@ -2490,45 +2646,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionSchema: FunctionSchema) = apply { - parameters = functionSchema.parameters - returns = functionSchema.returns - additionalProperties = functionSchema.additionalProperties.toMutableMap() - } + internal fun from(functionSchema: FunctionSchema) = + apply { + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() + } - fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } + fun parameters(parameters: JsonValue) = + apply { + this.parameters = parameters + } - fun returns(returns: JsonValue) = apply { this.returns = returns } + fun returns(returns: JsonValue) = + apply { + this.returns = returns + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionSchema = - FunctionSchema(parameters, returns, additionalProperties.toImmutable()) + FunctionSchema( + parameters, + returns, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2537,22 +2711,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2576,12 +2752,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2590,17 +2769,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2614,11 +2794,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2632,23 +2812,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2657,20 +2834,12 @@ private constructor( } @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("internal") - @ExcludeMissing - private val internal_: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Origin @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Id of the object the function is originating from */ @@ -2680,13 +2849,15 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -2694,10 +2865,12 @@ private constructor( fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ + @JsonProperty("internal") + @ExcludeMissing + fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing @@ -2705,16 +2878,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - internal_() - validated = true - } + objectId() + objectType() + internal_() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2724,12 +2898,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -2741,92 +2917,114 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - objectId = origin.objectId - objectType = origin.objectType - internal_ = origin.internal_ - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() + } /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } + fun internal_(internal_: JsonField) = + apply { + this.internal_ = internal_ + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - internal_, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + internal_, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2874,9 +3072,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2902,8 +3102,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2928,7 +3128,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2952,20 +3152,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2974,11 +3171,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2987,20 +3184,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index f2070a12..8076213e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a function object by its id */ -class FunctionDeleteParams -private constructor( +class FunctionDeleteParams private constructor( private val functionId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Function id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionDeleteParams]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionDeleteParams]. */ @@ -70,155 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionDeleteParams: FunctionDeleteParams) = apply { - functionId = functionDeleteParams.functionId - additionalHeaders = functionDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = functionDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = functionDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(functionDeleteParams: FunctionDeleteParams) = + apply { + functionId = functionDeleteParams.functionId + additionalHeaders = functionDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = functionDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = functionDeleteParams.additionalBodyProperties.toMutableMap() + } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = + apply { + this.functionId = functionId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): FunctionDeleteParams = FunctionDeleteParams( - checkRequired("functionId", functionId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "functionId", functionId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionDeleteParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionDeleteParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 2792f617..16df2c1f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -35,12 +35,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Invoke a function. */ -class FunctionInvokeParams -private constructor( +class FunctionInvokeParams private constructor( private val functionId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Function id */ @@ -59,8 +59,8 @@ private constructor( fun parent(): Optional = body.parent() /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(): Optional = body.stream() @@ -77,8 +77,8 @@ private constructor( fun _parent(): JsonField = body._parent() /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun _stream(): JsonField = body._stream() @@ -91,48 +91,40 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } /** The request to invoke a function */ @NoAutoDetect - class Body - @JsonCreator - private constructor( + class Body @JsonCreator private constructor( @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("messages") - @ExcludeMissing - private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("messages") @ExcludeMissing private val messages: JsonField> = JsonMissing.of(), @JsonProperty("mode") @ExcludeMissing private val mode: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - private val parent: JsonField = JsonMissing.of(), - @JsonProperty("stream") - @ExcludeMissing - private val stream: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("parent") @ExcludeMissing private val parent: JsonField = JsonMissing.of(), + @JsonProperty("stream") @ExcludeMissing private val stream: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Argument to the function, which can be any JSON serializable value */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** If the function is an LLM, additional messages to pass along to it */ - fun messages(): Optional> = - Optional.ofNullable(messages.getNullable("messages")) + fun messages(): Optional> = Optional.ofNullable(messages.getNullable("messages")) /** The mode format of the returned value (defaults to 'auto') */ fun mode(): Optional = Optional.ofNullable(mode.getNullable("mode")) @@ -141,8 +133,8 @@ private constructor( fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) @@ -155,19 +147,27 @@ private constructor( fun _messages(): JsonField> = messages /** The mode format of the returned value (defaults to 'auto') */ - @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + @JsonProperty("mode") + @ExcludeMissing + fun _mode(): JsonField = mode /** Options for tracing the function call */ - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + @JsonProperty("parent") + @ExcludeMissing + fun _parent(): JsonField = parent /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ - @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream + @JsonProperty("stream") + @ExcludeMissing + fun _stream(): JsonField = stream /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -175,25 +175,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - messages().ifPresent { it.forEach { it.validate() } } - mode() - parent().ifPresent { it.validate() } - stream() - version() - validated = true - } + messages().ifPresent { it.forEach { it.validate() } } + mode() + parent().ifPresent { it.validate() } + stream() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -208,34 +210,39 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - input = body.input - messages = body.messages.map { it.toMutableList() } - mode = body.mode - parent = body.parent - stream = body.stream - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + input = body.input + messages = body.messages.map { it.toMutableList() } + mode = body.mode + parent = body.parent + stream = body.stream + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** Argument to the function, which can be any JSON serializable value */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** If the function is an LLM, additional messages to pass along to it */ fun messages(messages: List) = messages(JsonField.of(messages)) /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: JsonField>) = apply { - this.messages = messages.map { it.toMutableList() } - } + fun messages(messages: JsonField>) = + apply { + this.messages = messages.map { it.toMutableList() } + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(message: Message) = apply { - messages = - (messages ?: JsonField.of(mutableListOf())).also { + fun addMessage(message: Message) = + apply { + messages = (messages ?: JsonField.of(mutableListOf())).also { checkKnown("messages", it).add(message) } - } + } /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) @@ -244,8 +251,7 @@ private constructor( fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(assistant: Message.Assistant) = - addMessage(Message.ofAssistant(assistant)) + fun addMessage(assistant: Message.Assistant) = addMessage(Message.ofAssistant(assistant)) /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) @@ -263,88 +269,106 @@ private constructor( fun mode(mode: Optional) = mode(mode.getOrNull()) /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: JsonField) = apply { this.mode = mode } + fun mode(mode: JsonField) = + apply { + this.mode = mode + } /** Options for tracing the function call */ fun parent(parent: Parent) = parent(JsonField.of(parent)) /** Options for tracing the function call */ - fun parent(parent: JsonField) = apply { this.parent = parent } + fun parent(parent: JsonField) = + apply { + this.parent = parent + } /** Span parent properties */ - fun parent(spanParentStruct: Parent.SpanParentStruct) = - parent(Parent.ofSpanParentStruct(spanParentStruct)) + fun parent(spanParentStruct: Parent.SpanParentStruct) = parent(Parent.ofSpanParentStruct(spanParentStruct)) /** The parent's span identifier, created by calling `.export()` on a span */ fun parent(string: String) = parent(Parent.ofString(string)) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Boolean?) = stream(JsonField.ofNullable(stream)) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Boolean) = stream(stream as Boolean?) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Optional) = stream(stream.getOrNull()) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ - fun stream(stream: JsonField) = apply { this.stream = stream } + fun stream(stream: JsonField) = + apply { + this.stream = stream + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - input, - (messages ?: JsonMissing.of()).map { it.toImmutable() }, - mode, - parent, - stream, - version, - additionalProperties.toImmutable(), + input, + (messages ?: JsonMissing.of()).map { it.toImmutable() }, + mode, + parent, + stream, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -353,8 +377,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "Body{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -362,14 +385,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionInvokeParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionInvokeParams]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionInvokeParams]. */ @@ -382,229 +408,326 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionInvokeParams: FunctionInvokeParams) = apply { - functionId = functionInvokeParams.functionId - body = functionInvokeParams.body.toBuilder() - additionalHeaders = functionInvokeParams.additionalHeaders.toBuilder() - additionalQueryParams = functionInvokeParams.additionalQueryParams.toBuilder() - } + internal fun from(functionInvokeParams: FunctionInvokeParams) = + apply { + functionId = functionInvokeParams.functionId + body = functionInvokeParams.body.toBuilder() + additionalHeaders = functionInvokeParams.additionalHeaders.toBuilder() + additionalQueryParams = functionInvokeParams.additionalQueryParams.toBuilder() + } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = + apply { + this.functionId = functionId + } /** Argument to the function, which can be any JSON serializable value */ - fun input(input: JsonValue) = apply { body.input(input) } + fun input(input: JsonValue) = + apply { + body.input(input) + } /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: List) = apply { body.messages(messages) } + fun messages(messages: List) = + apply { + body.messages(messages) + } /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: JsonField>) = apply { body.messages(messages) } + fun messages(messages: JsonField>) = + apply { + body.messages(messages) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(message: Message) = apply { body.addMessage(message) } + fun addMessage(message: Message) = + apply { + body.addMessage(message) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(system: Message.System) = apply { body.addMessage(system) } + fun addMessage(system: Message.System) = + apply { + body.addMessage(system) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(user: Message.User) = apply { body.addMessage(user) } + fun addMessage(user: Message.User) = + apply { + body.addMessage(user) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(assistant: Message.Assistant) = apply { body.addMessage(assistant) } + fun addMessage(assistant: Message.Assistant) = + apply { + body.addMessage(assistant) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(tool: Message.Tool) = apply { body.addMessage(tool) } + fun addMessage(tool: Message.Tool) = + apply { + body.addMessage(tool) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(function: Message.Function) = apply { body.addMessage(function) } + fun addMessage(function: Message.Function) = + apply { + body.addMessage(function) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(fallback: Message.Fallback) = apply { body.addMessage(fallback) } + fun addMessage(fallback: Message.Fallback) = + apply { + body.addMessage(fallback) + } /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: Mode?) = apply { body.mode(mode) } + fun mode(mode: Mode?) = + apply { + body.mode(mode) + } /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Optional) = mode(mode.getOrNull()) /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: JsonField) = apply { body.mode(mode) } + fun mode(mode: JsonField) = + apply { + body.mode(mode) + } /** Options for tracing the function call */ - fun parent(parent: Parent) = apply { body.parent(parent) } + fun parent(parent: Parent) = + apply { + body.parent(parent) + } /** Options for tracing the function call */ - fun parent(parent: JsonField) = apply { body.parent(parent) } + fun parent(parent: JsonField) = + apply { + body.parent(parent) + } /** Span parent properties */ - fun parent(spanParentStruct: Parent.SpanParentStruct) = apply { - body.parent(spanParentStruct) - } + fun parent(spanParentStruct: Parent.SpanParentStruct) = + apply { + body.parent(spanParentStruct) + } /** The parent's span identifier, created by calling `.export()` on a span */ - fun parent(string: String) = apply { body.parent(string) } + fun parent(string: String) = + apply { + body.parent(string) + } /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ - fun stream(stream: Boolean?) = apply { body.stream(stream) } + fun stream(stream: Boolean?) = + apply { + body.stream(stream) + } /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Boolean) = stream(stream as Boolean?) /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Optional) = stream(stream.getOrNull()) /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ - fun stream(stream: JsonField) = apply { body.stream(stream) } + fun stream(stream: JsonField) = + apply { + body.stream(stream) + } /** The version of the function */ - fun version(version: String) = apply { body.version(version) } + fun version(version: String) = + apply { + body.version(version) + } /** The version of the function */ - fun version(version: JsonField) = apply { body.version(version) } + fun version(version: JsonField) = + apply { + body.version(version) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionInvokeParams = FunctionInvokeParams( - checkRequired("functionId", functionId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "functionId", functionId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( + class Message private constructor( private val system: System? = null, private val user: User? = null, private val assistant: Assistant? = null, @@ -612,6 +735,7 @@ private constructor( private val function: Function? = null, private val fallback: Fallback? = null, private val _json: JsonValue? = null, + ) { fun system(): Optional = Optional.ofNullable(system) @@ -653,60 +777,59 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - system != null -> visitor.visitSystem(system) - user != null -> visitor.visitUser(user) - assistant != null -> visitor.visitAssistant(assistant) - tool != null -> visitor.visitTool(tool) - function != null -> visitor.visitFunction(function) - fallback != null -> visitor.visitFallback(fallback) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Message = apply { - if (validated) { - return@apply - } + fun validate(): Message = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitSystem(system: System) { - system.validate() + system.validate() } override fun visitUser(user: User) { - user.validate() + user.validate() } override fun visitAssistant(assistant: Assistant) { - assistant.validate() + assistant.validate() } override fun visitTool(tool: Tool) { - tool.validate() + tool.validate() } override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitFallback(fallback: Fallback) { - fallback.validate() + fallback.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ + return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ @@ -725,21 +848,28 @@ private constructor( companion object { - @JvmStatic fun ofSystem(system: System) = Message(system = system) + @JvmStatic + fun ofSystem(system: System) = Message(system = system) - @JvmStatic fun ofUser(user: User) = Message(user = user) + @JvmStatic + fun ofUser(user: User) = Message(user = user) - @JvmStatic fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) + @JvmStatic + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) + @JvmStatic + fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic fun ofFunction(function: Function) = Message(function = function) + @JvmStatic + fun ofFunction(function: Function) = Message(function = function) - @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) + @JvmStatic + fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } /** - * An interface that defines how to map each variant of [Message] to a value of type [T]. + * An interface that defines how to map each variant of [Message] to a value of + * type [T]. */ interface Visitor { @@ -758,87 +888,69 @@ private constructor( /** * Maps an unknown variant of [Message] to a value of type [T]. * - * An instance of [Message] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Message] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } internal class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(fallback = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } internal class Serializer : BaseSerializer(Message::class) { - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } @NoAutoDetect - class System - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class System @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") @@ -847,11 +959,17 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -859,16 +977,17 @@ private constructor( private var validated: Boolean = false - fun validate(): System = apply { - if (validated) { - return@apply - } + fun validate(): System = + apply { + if (validated) { + return@apply + } - role() - content() - name() - validated = true - } + role() + content() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -878,11 +997,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [System]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [System]. */ @@ -894,58 +1015,76 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(system: System) = apply { - role = system.role - content = system.content - name = system.name - additionalProperties = system.additionalProperties.toMutableMap() - } + internal fun from(system: System) = + apply { + role = system.role + content = system.content + name = system.name + additionalProperties = system.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): System = System( - checkRequired("role", role), - content, - name, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + name, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -955,7 +1094,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -966,23 +1106,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - SYSTEM + SYSTEM, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { SYSTEM, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1006,7 +1146,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1021,19 +1161,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1042,11 +1179,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1055,25 +1192,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class User - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class User @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") @@ -1082,11 +1210,17 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1094,16 +1228,17 @@ private constructor( private var validated: Boolean = false - fun validate(): User = apply { - if (validated) { - return@apply - } + fun validate(): User = + apply { + if (validated) { + return@apply + } - role() - content().ifPresent { it.validate() } - name() - validated = true - } + role() + content().ifPresent { it.validate() } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1113,11 +1248,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [User]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [User]. */ @@ -1129,63 +1266,80 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(user: User) = apply { - role = user.role - content = user.content - name = user.name - additionalProperties = user.additionalProperties.toMutableMap() - } + internal fun from(user: User) = + apply { + role = user.role + content = user.content + name = user.name + additionalProperties = user.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: Content) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun content(text: String) = content(Content.ofText(text)) - fun contentOfArray(array: List) = - content(Content.ofArray(array)) + fun contentOfArray(array: List) = content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): User = User( - checkRequired("role", role), - content, - name, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + name, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1195,7 +1349,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1206,23 +1361,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - USER + USER, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { USER, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1246,7 +1401,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1261,19 +1416,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1283,11 +1435,11 @@ private constructor( @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( + class Content private constructor( private val text: String? = null, private val array: List? = null, private val _json: JsonValue? = null, + ) { fun text(): Optional = Optional.ofNullable(text) @@ -1305,38 +1457,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Content = apply { - if (validated) { - return@apply - } + fun validate(): Content = + apply { + if (validated) { + return@apply + } + + accept(object : Visitor { + override fun visitText(text: String) { - accept( - object : Visitor { - override fun visitText(text: String) {} + } override fun visitArray(array: List) { - array.forEach { it.validate() } + array.forEach { it.validate() } } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, array) /* spotless:on */ @@ -1351,15 +1504,16 @@ private constructor( companion object { - @JvmStatic fun ofText(text: String) = Content(text = text) + @JvmStatic + fun ofText(text: String) = Content(text = text) @JvmStatic fun ofArray(array: List) = Content(array = array) } /** - * An interface that defines how to map each variant of [Content] to a value of type - * [T]. + * An interface that defines how to map each variant of [Content] to a value of + * type [T]. */ interface Visitor { @@ -1370,66 +1524,58 @@ private constructor( /** * Maps an unknown variant of [Content] to a value of type [T]. * - * An instance of [Content] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * An instance of [Content] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } internal class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Content(array = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Content(array = it, _json = json) + } - return Content(_json = json) + return Content(_json = json) } } internal class Serializer : BaseSerializer(Content::class) { - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( + class ChatCompletionContentPart private constructor( private val text: ChatCompletionContentPartText? = null, private val image: ChatCompletionContentPartImage? = null, private val _json: JsonValue? = null, + ) { fun text(): Optional = Optional.ofNullable(text) - fun image(): Optional = - Optional.ofNullable(image) + fun image(): Optional = Optional.ofNullable(image) fun isText(): Boolean = text != null @@ -1442,40 +1588,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - image != null -> visitor.visitImage(image) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ChatCompletionContentPart = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPart = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitText(text: ChatCompletionContentPartText) { - text.validate() + text.validate() } override fun visitImage(image: ChatCompletionContentPartImage) { - image.validate() + image.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, image) /* spotless:on */ @@ -1491,17 +1636,15 @@ private constructor( companion object { @JvmStatic - fun ofText(text: ChatCompletionContentPartText) = - ChatCompletionContentPart(text = text) + fun ofText(text: ChatCompletionContentPartText) = ChatCompletionContentPart(text = text) @JvmStatic - fun ofImage(image: ChatCompletionContentPartImage) = - ChatCompletionContentPart(image = image) + fun ofImage(image: ChatCompletionContentPartImage) = ChatCompletionContentPart(image = image) } /** - * An interface that defines how to map each variant of - * [ChatCompletionContentPart] to a value of type [T]. + * An interface that defines how to map each variant of [ChatCompletionContentPart] + * to a value of type [T]. */ interface Visitor { @@ -1510,78 +1653,56 @@ private constructor( fun visitImage(image: ChatCompletionContentPartImage): T /** - * Maps an unknown variant of [ChatCompletionContentPart] to a value of type - * [T]. + * Maps an unknown variant of [ChatCompletionContentPart] to a value of type [T]. * - * An instance of [ChatCompletionContentPart] can contain an unknown variant - * if it was deserialized from data that doesn't match any known variant. - * For example, if the SDK is on an older version than the API, then the API - * may respond with new variants that the SDK is unaware of. + * An instance of [ChatCompletionContentPart] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") } } - internal class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { + internal class Deserializer : BaseDeserializer(ChatCompletionContentPart::class) { - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart(image = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ChatCompletionContentPart(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ChatCompletionContentPart(image = it, _json = json) + } - return ChatCompletionContentPart(_json = json) + return ChatCompletionContentPart(_json = json) } } - internal class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.image != null -> generator.writeObject(value.image) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid ChatCompletionContentPart") - } + internal class Serializer : BaseSerializer(ChatCompletionContentPart::class) { + + override fun serialize(value: ChatCompletionContentPart, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1590,55 +1711,45 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Assistant - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("function_call") - @ExcludeMissing - private val functionCall: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tool_calls") - @ExcludeMissing - private val toolCalls: JsonField> = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Assistant @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("tool_calls") @ExcludeMissing private val toolCalls: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall(): JsonField = functionCall - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("tool_calls") @ExcludeMissing @@ -1650,18 +1761,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Assistant = apply { - if (validated) { - return@apply - } + fun validate(): Assistant = + apply { + if (validated) { + return@apply + } - role() - content() - functionCall().ifPresent { it.validate() } - name() - toolCalls().ifPresent { it.forEach { it.validate() } } - validated = true - } + role() + content() + functionCall().ifPresent { it.validate() } + name() + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true + } fun toBuilder() = Builder().from(this) @@ -1671,11 +1783,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Assistant]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Assistant]. */ @@ -1689,93 +1803,109 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(assistant: Assistant) = apply { - role = assistant.role - content = assistant.content - functionCall = assistant.functionCall - name = assistant.name - toolCalls = assistant.toolCalls.map { it.toMutableList() } - additionalProperties = assistant.additionalProperties.toMutableMap() - } + internal fun from(assistant: Assistant) = + apply { + role = assistant.role + content = assistant.content + functionCall = assistant.functionCall + name = assistant.name + toolCalls = assistant.toolCalls.map { it.toMutableList() } + additionalProperties = assistant.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } - fun functionCall(functionCall: FunctionCall?) = - functionCall(JsonField.ofNullable(functionCall)) + fun functionCall(functionCall: FunctionCall?) = functionCall(JsonField.ofNullable(functionCall)) - fun functionCall(functionCall: Optional) = - functionCall(functionCall.getOrNull()) + fun functionCall(functionCall: Optional) = functionCall(functionCall.getOrNull()) - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } + fun functionCall(functionCall: JsonField) = + apply { + this.functionCall = functionCall + } fun name(name: String?) = name(JsonField.ofNullable(name)) fun name(name: Optional) = name(name.getOrNull()) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun toolCalls(toolCalls: List?) = - toolCalls(JsonField.ofNullable(toolCalls)) + fun toolCalls(toolCalls: List?) = toolCalls(JsonField.ofNullable(toolCalls)) - fun toolCalls(toolCalls: Optional>) = - toolCalls(toolCalls.getOrNull()) + fun toolCalls(toolCalls: Optional>) = toolCalls(toolCalls.getOrNull()) - fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls.map { it.toMutableList() } - } + fun toolCalls(toolCalls: JsonField>) = + apply { + this.toolCalls = toolCalls.map { it.toMutableList() } + } - fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { - toolCalls = - (toolCalls ?: JsonField.of(mutableListOf())).also { + fun addToolCall(toolCall: ChatCompletionMessageToolCall) = + apply { + toolCalls = (toolCalls ?: JsonField.of(mutableListOf())).also { checkKnown("toolCalls", it).add(toolCall) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Assistant = Assistant( - checkRequired("role", role), - content, - functionCall, - name, - (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + functionCall, + name, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1785,7 +1915,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1796,23 +1927,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - ASSISTANT + ASSISTANT, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { ASSISTANT, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1836,7 +1967,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1851,19 +1982,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1872,17 +2000,11 @@ private constructor( } @NoAutoDetect - class FunctionCall - @JsonCreator - private constructor( - @JsonProperty("arguments") - @ExcludeMissing - private val arguments: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class FunctionCall @JsonCreator private constructor( + @JsonProperty("arguments") @ExcludeMissing private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun arguments(): String = arguments.getRequired("arguments") @@ -1893,7 +2015,9 @@ private constructor( @ExcludeMissing fun _arguments(): JsonField = arguments - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1901,15 +2025,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionCall = apply { - if (validated) { - return@apply - } + fun validate(): FunctionCall = + apply { + if (validated) { + return@apply + } - arguments() - name() - validated = true - } + arguments() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1919,12 +2044,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [FunctionCall]. * * The following fields are required: + * * ```java * .arguments() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionCall]. */ @@ -1935,58 +2062,71 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - arguments = functionCall.arguments - name = functionCall.name - additionalProperties = functionCall.additionalProperties.toMutableMap() - } + internal fun from(functionCall: FunctionCall) = + apply { + arguments = functionCall.arguments + name = functionCall.name + additionalProperties = functionCall.additionalProperties.toMutableMap() + } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } + fun arguments(arguments: JsonField) = + apply { + this.arguments = arguments + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionCall = FunctionCall( - checkRequired("arguments", arguments), - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "arguments", arguments + ), + checkRequired( + "name", name + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1995,16 +2135,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2013,37 +2152,31 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Tool - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("tool_call_id") - @ExcludeMissing - private val toolCallId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Tool @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("tool_call_id") @ExcludeMissing private val toolCallId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun toolCallId(): Optional = - Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonProperty("tool_call_id") @ExcludeMissing @@ -2055,16 +2188,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Tool = apply { - if (validated) { - return@apply - } + fun validate(): Tool = + apply { + if (validated) { + return@apply + } - role() - content() - toolCallId() - validated = true - } + role() + content() + toolCallId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2074,11 +2208,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Tool]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Tool]. */ @@ -2090,60 +2226,76 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tool: Tool) = apply { - role = tool.role - content = tool.content - toolCallId = tool.toolCallId - additionalProperties = tool.additionalProperties.toMutableMap() - } + internal fun from(tool: Tool) = + apply { + role = tool.role + content = tool.content + toolCallId = tool.toolCallId + additionalProperties = tool.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } + fun toolCallId(toolCallId: JsonField) = + apply { + this.toolCallId = toolCallId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Tool = Tool( - checkRequired("role", role), - content, - toolCallId, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + toolCallId, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2153,7 +2305,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2164,23 +2317,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - TOOL + TOOL, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { TOOL, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2204,7 +2357,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2219,19 +2372,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2240,11 +2390,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2253,25 +2403,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") @@ -2280,11 +2421,17 @@ private constructor( fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing @@ -2292,16 +2439,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - name() - role() - content() - validated = true - } + name() + role() + content() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2311,12 +2459,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .name() * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -2328,58 +2478,78 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - name = function.name - role = function.role - content = function.content - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + name = function.name + role = function.role + content = function.content + additionalProperties = function.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("name", name), - checkRequired("role", role), - content, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "role", role + ), + content, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2389,7 +2559,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2400,23 +2571,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { FUNCTION, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2440,7 +2611,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2455,19 +2626,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2476,11 +2644,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2489,31 +2657,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Fallback - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Fallback @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing @@ -2521,15 +2686,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Fallback = apply { - if (validated) { - return@apply - } + fun validate(): Fallback = + apply { + if (validated) { + return@apply + } - role() - content() - validated = true - } + role() + content() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2539,11 +2705,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Fallback]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Fallback]. */ @@ -2554,54 +2722,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fallback: Fallback) = apply { - role = fallback.role - content = fallback.content - additionalProperties = fallback.additionalProperties.toMutableMap() - } + internal fun from(fallback: Fallback) = + apply { + role = fallback.role + content = fallback.content + additionalProperties = fallback.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Fallback = Fallback( - checkRequired("role", role), - content, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2611,7 +2794,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2622,23 +2806,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - MODEL + MODEL, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { MODEL, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2662,7 +2846,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2677,19 +2861,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2698,11 +2879,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2711,23 +2892,26 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" } } /** The mode format of the returned value (defaults to 'auto') */ - class Mode @JsonCreator private constructor(private val value: JsonField) : Enum { + class Mode @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2748,9 +2932,11 @@ private constructor( * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Mode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2761,11 +2947,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2777,11 +2963,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2793,23 +2979,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ + return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2820,11 +3003,11 @@ private constructor( /** Options for tracing the function call */ @JsonDeserialize(using = Parent.Deserializer::class) @JsonSerialize(using = Parent.Serializer::class) - class Parent - private constructor( + class Parent private constructor( private val spanParentStruct: SpanParentStruct? = null, private val string: String? = null, private val _json: JsonValue? = null, + ) { /** Span parent properties */ @@ -2846,38 +3029,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - spanParentStruct != null -> visitor.visitSpanParentStruct(spanParentStruct) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + return when { + spanParentStruct != null -> visitor.visitSpanParentStruct(spanParentStruct) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Parent = apply { - if (validated) { - return@apply - } + fun validate(): Parent = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitSpanParentStruct(spanParentStruct: SpanParentStruct) { - spanParentStruct.validate() + spanParentStruct.validate() } - override fun visitString(string: String) {} - } - ) - validated = true - } + override fun visitString(string: String) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + } + }) + validated = true } - return /* spotless:off */ other is Parent && spanParentStruct == other.spanParentStruct && string == other.string /* spotless:on */ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Parent && spanParentStruct == other.spanParentStruct && string == other.string /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanParentStruct, string) /* spotless:on */ @@ -2894,14 +3078,17 @@ private constructor( /** Span parent properties */ @JvmStatic - fun ofSpanParentStruct(spanParentStruct: SpanParentStruct) = - Parent(spanParentStruct = spanParentStruct) + fun ofSpanParentStruct(spanParentStruct: SpanParentStruct) = Parent(spanParentStruct = spanParentStruct) /** The parent's span identifier, created by calling `.export()` on a span */ - @JvmStatic fun ofString(string: String) = Parent(string = string) + @JvmStatic + fun ofString(string: String) = Parent(string = string) } - /** An interface that defines how to map each variant of [Parent] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Parent] to a value of type + * [T]. + */ interface Visitor { /** Span parent properties */ @@ -2913,70 +3100,55 @@ private constructor( /** * Maps an unknown variant of [Parent] to a value of type [T]. * - * An instance of [Parent] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Parent] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Parent: $json") + throw BraintrustInvalidDataException("Unknown Parent: $json") } } internal class Deserializer : BaseDeserializer(Parent::class) { override fun ObjectCodec.deserialize(node: JsonNode): Parent { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Parent(spanParentStruct = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Parent(string = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Parent(spanParentStruct = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Parent(string = it, _json = json) + } - return Parent(_json = json) + return Parent(_json = json) } } internal class Serializer : BaseSerializer(Parent::class) { - override fun serialize( - value: Parent, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.spanParentStruct != null -> generator.writeObject(value.spanParentStruct) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parent") - } + override fun serialize(value: Parent, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.spanParentStruct != null -> generator.writeObject(value.spanParentStruct) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Parent") + } } } /** Span parent properties */ @NoAutoDetect - class SpanParentStruct - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("propagated_event") - @ExcludeMissing - private val propagatedEvent: JsonField = JsonMissing.of(), - @JsonProperty("row_ids") - @ExcludeMissing - private val rowIds: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class SpanParentStruct @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("propagated_event") @ExcludeMissing private val propagatedEvent: JsonField = JsonMissing.of(), + @JsonProperty("row_ids") @ExcludeMissing private val rowIds: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the container object you are logging to */ @@ -2985,14 +3157,15 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** Include these properties in every span created under this parent */ - fun propagatedEvent(): Optional = - Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) + fun propagatedEvent(): Optional = Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) /** Identifiers for the row to to log a subspan under */ fun rowIds(): Optional = Optional.ofNullable(rowIds.getNullable("row_ids")) /** The id of the container object you are logging to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId @JsonProperty("object_type") @ExcludeMissing @@ -3004,7 +3177,9 @@ private constructor( fun _propagatedEvent(): JsonField = propagatedEvent /** Identifiers for the row to to log a subspan under */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField = rowIds + @JsonProperty("row_ids") + @ExcludeMissing + fun _rowIds(): JsonField = rowIds @JsonAnyGetter @ExcludeMissing @@ -3012,17 +3187,18 @@ private constructor( private var validated: Boolean = false - fun validate(): SpanParentStruct = apply { - if (validated) { - return@apply - } + fun validate(): SpanParentStruct = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - propagatedEvent().ifPresent { it.validate() } - rowIds().ifPresent { it.validate() } - validated = true - } + objectId() + objectType() + propagatedEvent().ifPresent { it.validate() } + rowIds().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -3032,12 +3208,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [SpanParentStruct]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanParentStruct]. */ @@ -3050,38 +3228,42 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanParentStruct: SpanParentStruct) = apply { - objectId = spanParentStruct.objectId - objectType = spanParentStruct.objectType - propagatedEvent = spanParentStruct.propagatedEvent - rowIds = spanParentStruct.rowIds - additionalProperties = spanParentStruct.additionalProperties.toMutableMap() - } + internal fun from(spanParentStruct: SpanParentStruct) = + apply { + objectId = spanParentStruct.objectId + objectType = spanParentStruct.objectType + propagatedEvent = spanParentStruct.propagatedEvent + rowIds = spanParentStruct.rowIds + additionalProperties = spanParentStruct.additionalProperties.toMutableMap() + } /** The id of the container object you are logging to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the container object you are logging to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: PropagatedEvent?) = - propagatedEvent(JsonField.ofNullable(propagatedEvent)) + fun propagatedEvent(propagatedEvent: PropagatedEvent?) = propagatedEvent(JsonField.ofNullable(propagatedEvent)) /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: Optional) = - propagatedEvent(propagatedEvent.getOrNull()) + fun propagatedEvent(propagatedEvent: Optional) = propagatedEvent(propagatedEvent.getOrNull()) /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: JsonField) = apply { - this.propagatedEvent = propagatedEvent - } + fun propagatedEvent(propagatedEvent: JsonField) = + apply { + this.propagatedEvent = propagatedEvent + } /** Identifiers for the row to to log a subspan under */ fun rowIds(rowIds: RowIds?) = rowIds(JsonField.ofNullable(rowIds)) @@ -3090,43 +3272,55 @@ private constructor( fun rowIds(rowIds: Optional) = rowIds(rowIds.getOrNull()) /** Identifiers for the row to to log a subspan under */ - fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } + fun rowIds(rowIds: JsonField) = + apply { + this.rowIds = rowIds + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SpanParentStruct = SpanParentStruct( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - propagatedEvent, - rowIds, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + propagatedEvent, + rowIds, + additionalProperties.toImmutable(), ) } - class ObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -3136,7 +3330,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -3157,9 +3352,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -3193,7 +3390,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3209,19 +3406,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3231,11 +3425,9 @@ private constructor( /** Include these properties in every span created under this parent */ @NoAutoDetect - class PropagatedEvent - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class PropagatedEvent @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -3244,22 +3436,22 @@ private constructor( private var validated: Boolean = false - fun validate(): PropagatedEvent = apply { - if (validated) { - return@apply - } + fun validate(): PropagatedEvent = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [PropagatedEvent]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [PropagatedEvent]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [PropagatedEvent]. */ @@ -3268,42 +3460,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(propagatedEvent: PropagatedEvent) = apply { - additionalProperties = propagatedEvent.additionalProperties.toMutableMap() - } + internal fun from(propagatedEvent: PropagatedEvent) = + apply { + additionalProperties = propagatedEvent.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } - fun build(): PropagatedEvent = - PropagatedEvent(additionalProperties.toImmutable()) + fun build(): PropagatedEvent = PropagatedEvent(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PropagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PropagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3312,26 +3508,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PropagatedEvent{additionalProperties=$additionalProperties}" + override fun toString() = "PropagatedEvent{additionalProperties=$additionalProperties}" } /** Identifiers for the row to to log a subspan under */ @NoAutoDetect - class RowIds - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RowIds @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the row */ @@ -3344,7 +3531,9 @@ private constructor( fun spanId(): String = spanId.getRequired("span_id") /** The id of the row */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** The root_span_id of the row */ @JsonProperty("root_span_id") @@ -3352,7 +3541,9 @@ private constructor( fun _rootSpanId(): JsonField = rootSpanId /** The span_id of the row */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId @JsonAnyGetter @ExcludeMissing @@ -3360,16 +3551,17 @@ private constructor( private var validated: Boolean = false - fun validate(): RowIds = apply { - if (validated) { - return@apply - } + fun validate(): RowIds = + apply { + if (validated) { + return@apply + } - id() - rootSpanId() - spanId() - validated = true - } + id() + rootSpanId() + spanId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3379,13 +3571,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [RowIds]. * * The following fields are required: + * * ```java * .id() * .rootSpanId() * .spanId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RowIds]. */ @@ -3397,70 +3591,88 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(rowIds: RowIds) = apply { - id = rowIds.id - rootSpanId = rowIds.rootSpanId - spanId = rowIds.spanId - additionalProperties = rowIds.additionalProperties.toMutableMap() - } + internal fun from(rowIds: RowIds) = + apply { + id = rowIds.id + rootSpanId = rowIds.rootSpanId + spanId = rowIds.spanId + additionalProperties = rowIds.additionalProperties.toMutableMap() + } /** The id of the row */ fun id(id: String) = id(JsonField.of(id)) /** The id of the row */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** The root_span_id of the row */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** The root_span_id of the row */ - fun rootSpanId(rootSpanId: JsonField) = apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** The span_id of the row */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** The span_id of the row */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RowIds = RowIds( - checkRequired("id", id), - checkRequired("rootSpanId", rootSpanId), - checkRequired("spanId", spanId), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "rootSpanId", rootSpanId + ), + checkRequired( + "spanId", spanId + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RowIds && id == other.id && rootSpanId == other.rootSpanId && spanId == other.spanId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RowIds && id == other.id && rootSpanId == other.rootSpanId && spanId == other.spanId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3469,16 +3681,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RowIds{id=$id, rootSpanId=$rootSpanId, spanId=$spanId, additionalProperties=$additionalProperties}" + override fun toString() = "RowIds{id=$id, rootSpanId=$rootSpanId, spanId=$spanId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanParentStruct && objectId == other.objectId && objectType == other.objectType && propagatedEvent == other.propagatedEvent && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanParentStruct && objectId == other.objectId && objectType == other.objectType && propagatedEvent == other.propagatedEvent && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3487,21 +3698,19 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SpanParentStruct{objectId=$objectId, objectType=$objectType, propagatedEvent=$propagatedEvent, rowIds=$rowIds, additionalProperties=$additionalProperties}" + override fun toString() = "SpanParentStruct{objectId=$objectId, objectType=$objectType, propagatedEvent=$propagatedEvent, rowIds=$rowIds, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionInvokeParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionInvokeParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index 3320310c..721e7224 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -13,10 +13,9 @@ import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects @NoAutoDetect -class FunctionInvokeResponse -@JsonCreator -private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap() +class FunctionInvokeResponse @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -25,20 +24,25 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionInvokeResponse = apply { - if (validated) { - return@apply - } + fun validate(): FunctionInvokeResponse = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [FunctionInvokeResponse]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [FunctionInvokeResponse]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionInvokeResponse]. */ @@ -47,39 +51,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionInvokeResponse: FunctionInvokeResponse) = apply { - additionalProperties = functionInvokeResponse.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): FunctionInvokeResponse = - FunctionInvokeResponse(additionalProperties.toImmutable()) + internal fun from(functionInvokeResponse: FunctionInvokeResponse) = + apply { + additionalProperties = functionInvokeResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): FunctionInvokeResponse = FunctionInvokeResponse(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionInvokeResponse && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeResponse && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 1ed3037c..27c52924 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.FunctionService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all functions. The functions are sorted by creation date, with the most recently-created - * functions coming first + * List out all functions. The functions are sorted by creation date, with the most + * recently-created functions coming first */ -class FunctionListPage -private constructor( +class FunctionListPage private constructor( private val functionsService: FunctionService, private val params: FunctionListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionListPage && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is FunctionListPage && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ - override fun toString() = - "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" + override fun toString() = "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - FunctionListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - FunctionListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { functionsService.list(it) } + return getNextPageParams().map { functionsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -84,16 +74,18 @@ private constructor( @JvmStatic fun of(functionsService: FunctionService, params: FunctionListParams, response: Response) = - FunctionListPage(functionsService, params, response) + FunctionListPage( + functionsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -107,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [FunctionListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -143,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: FunctionListPage) : Iterable { + class AutoPager( + private val firstPage: FunctionListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index 4b4eebea..636c7970 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.FunctionServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all functions. The functions are sorted by creation date, with the most recently-created - * functions coming first + * List out all functions. The functions are sorted by creation date, with the most + * recently-created functions coming first */ -class FunctionListPageAsync -private constructor( +class FunctionListPageAsync private constructor( private val functionsService: FunctionServiceAsync, private val params: FunctionListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionListPageAsync && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is FunctionListPageAsync && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ - override fun toString() = - "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" + override fun toString() = "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - FunctionListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - FunctionListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { functionsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + functionsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,20 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - functionsService: FunctionServiceAsync, - params: FunctionListParams, - response: Response, - ) = FunctionListPageAsync(functionsService, params, response) + fun of(functionsService: FunctionServiceAsync, params: FunctionListParams, response: Response) = + FunctionListPageAsync( + functionsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -112,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [FunctionListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -150,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: FunctionListPageAsync) { + class AutoPager( + private val firstPage: FunctionListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Function) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Function) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index aaf2b9ca..f40f98e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all functions. The functions are sorted by creation date, with the most recently-created - * functions coming first + * List out all functions. The functions are sorted by creation date, with the most + * recently-created functions coming first */ -class FunctionListParams -private constructor( +class FunctionListParams private constructor( private val endingBefore: String?, private val functionName: String?, private val ids: Ids?, @@ -40,14 +39,15 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -55,8 +55,8 @@ private constructor( fun functionName(): Optional = Optional.ofNullable(functionName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -78,17 +78,17 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ fun version(): Optional = Optional.ofNullable(version) @@ -99,29 +99,71 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.functionName?.let { queryParams.put("function_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.slug?.let { queryParams.put("slug", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.functionName?.let { + queryParams.put( + "function_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.slug?.let { + queryParams.put( + "slug", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): FunctionListParams = builder().build() + @JvmStatic + fun none(): FunctionListParams = builder().build() /** Returns a mutable builder for constructing an instance of [FunctionListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionListParams]. */ @@ -142,71 +184,84 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionListParams: FunctionListParams) = apply { - endingBefore = functionListParams.endingBefore - functionName = functionListParams.functionName - ids = functionListParams.ids - limit = functionListParams.limit - orgName = functionListParams.orgName - projectId = functionListParams.projectId - projectName = functionListParams.projectName - slug = functionListParams.slug - startingAfter = functionListParams.startingAfter - version = functionListParams.version - additionalHeaders = functionListParams.additionalHeaders.toBuilder() - additionalQueryParams = functionListParams.additionalQueryParams.toBuilder() - } + internal fun from(functionListParams: FunctionListParams) = + apply { + endingBefore = functionListParams.endingBefore + functionName = functionListParams.functionName + ids = functionListParams.ids + limit = functionListParams.limit + orgName = functionListParams.orgName + projectId = functionListParams.projectId + projectName = functionListParams.projectName + slug = functionListParams.slug + startingAfter = functionListParams.startingAfter + version = functionListParams.version + additionalHeaders = functionListParams.additionalHeaders.toBuilder() + additionalQueryParams = functionListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the function to search for */ - fun functionName(functionName: String?) = apply { this.functionName = functionName } + fun functionName(functionName: String?) = + apply { + this.functionName = functionName + } /** Name of the function to search for */ fun functionName(functionName: Optional) = functionName(functionName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -215,25 +270,37 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Retrieve prompt with a specific slug */ - fun slug(slug: String?) = apply { this.slug = slug } + fun slug(slug: String?) = + apply { + this.slug = slug + } /** Retrieve prompt with a specific slug */ fun slug(slug: Optional) = slug(slug.getOrNull()) @@ -241,164 +308,195 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionListParams = FunctionListParams( - endingBefore, - functionName, - ids, - limit, - orgName, - projectId, - projectName, - slug, - startingAfter, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + functionName, + ids, + limit, + orgName, + projectId, + projectName, + slug, + startingAfter, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -416,19 +514,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -443,12 +541,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -458,60 +561,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionListParams && endingBefore == other.endingBefore && functionName == other.functionName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionListParams && endingBefore == other.endingBefore && functionName == other.functionName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt index bf5891ce..ac1320ef 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,14 +35,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace function. If there is an existing function in the project with the same slug as - * the one specified in the request, will replace the existing function with the provided fields + * Create or replace function. If there is an existing function in the project with + * the same slug as the one specified in the request, will replace the existing + * function with the provided fields */ -class FunctionReplaceParams -private constructor( +class FunctionReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { fun functionData(): FunctionData = body.functionData() @@ -105,48 +106,27 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("function_data") - @ExcludeMissing - private val functionData: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_schema") - @ExcludeMissing - private val functionSchema: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") @ExcludeMissing private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun functionData(): FunctionData = functionData.getRequired("function_data") @@ -161,21 +141,17 @@ private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = - Optional.ofNullable(functionSchema.getNullable("function_schema")) + fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -185,13 +161,19 @@ private constructor( fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -207,7 +189,9 @@ private constructor( @ExcludeMissing fun _functionType(): JsonField = functionType - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -215,7 +199,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -223,23 +209,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } - - functionData().validate() - name() - projectId() - slug() - description() - functionSchema().ifPresent { it.validate() } - functionType() - origin().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + functionData().validate() + name() + projectId() + slug() + description() + functionSchema().ifPresent { it.validate() } + functionType() + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -249,6 +236,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .functionData() * .name() @@ -256,7 +244,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -275,51 +264,60 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - functionData = body.functionData - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionSchema = body.functionSchema - functionType = body.functionType - origin = body.origin - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + functionData = body.functionData + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionSchema = body.functionSchema + functionType = body.functionType + origin = body.origin + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = + apply { + this.functionData = functionData + } - fun functionData(prompt: FunctionData.Prompt) = - functionData(FunctionData.ofPrompt(prompt)) + fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) - fun functionData(global: FunctionData.Global) = - functionData(FunctionData.ofGlobal(global)) + fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -328,38 +326,40 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = - functionSchema(JsonField.ofNullable(functionSchema)) + fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - this.functionSchema = functionSchema - } + fun functionSchema(functionSchema: JsonField) = + apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -368,9 +368,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -379,57 +380,75 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("functionData", functionData), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - description, - functionSchema, - functionType, - origin, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "functionData", functionData + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + description, + functionSchema, + functionType, + origin, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -438,8 +457,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -447,9 +465,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionReplaceParams]. * * The following fields are required: + * * ```java * .functionData() * .name() @@ -457,7 +477,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionReplaceParams]. */ @@ -469,234 +490,331 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionReplaceParams: FunctionReplaceParams) = apply { - body = functionReplaceParams.body.toBuilder() - additionalHeaders = functionReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = functionReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(functionReplaceParams: FunctionReplaceParams) = + apply { + body = functionReplaceParams.body.toBuilder() + additionalHeaders = functionReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = functionReplaceParams.additionalQueryParams.toBuilder() + } - fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + fun functionData(functionData: FunctionData) = + apply { + body.functionData(functionData) + } - fun functionData(functionData: JsonField) = apply { - body.functionData(functionData) - } + fun functionData(functionData: JsonField) = + apply { + body.functionData(functionData) + } - fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + fun functionData(prompt: FunctionData.Prompt) = + apply { + body.functionData(prompt) + } - fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + fun functionData(code: FunctionData.Code) = + apply { + body.functionData(code) + } - fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } + fun functionData(global: FunctionData.Global) = + apply { + body.functionData(global) + } /** Name of the prompt */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { body.slug(slug) } + fun slug(slug: String) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: FunctionSchema?) = + apply { + body.functionSchema(functionSchema) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: JsonField) = + apply { + body.functionSchema(functionSchema) + } - fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + fun functionType(functionType: FunctionType?) = + apply { + body.functionType(functionType) + } - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = + apply { + body.functionType(functionType) + } - fun origin(origin: Origin?) = apply { body.origin(origin) } + fun origin(origin: Origin?) = + apply { + body.origin(origin) + } fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { body.origin(origin) } + fun origin(origin: JsonField) = + apply { + body.origin(origin) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionReplaceParams = FunctionReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( + class FunctionData private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -720,45 +838,44 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ @@ -774,16 +891,19 @@ private constructor( companion object { - @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic + fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic + fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic + fun ofGlobal(global: Global) = FunctionData(global = global) } /** - * An interface that defines how to map each variant of [FunctionData] to a value of type - * [T]. + * An interface that defines how to map each variant of [FunctionData] to a value + * of type [T]. */ interface Visitor { @@ -796,71 +916,62 @@ private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(global = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize( - value: FunctionData, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Prompt @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -868,14 +979,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -885,11 +997,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -899,43 +1013,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt(checkRequired("type", type), additionalProperties.toImmutable()) + Prompt( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -945,7 +1073,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -956,23 +1085,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT + PROMPT, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { PROMPT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -996,7 +1125,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1011,19 +1140,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1032,11 +1158,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1045,31 +1171,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code - @JsonCreator - private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Code @JsonCreator private constructor( + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1077,15 +1200,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Code = apply { - if (validated) { - return@apply - } + fun validate(): Code = + apply { + if (validated) { + return@apply + } - data().validate() - type() - validated = true - } + data().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1095,12 +1219,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: + * * ```java * .data() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Code]. */ @@ -1111,15 +1237,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = + apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -1127,45 +1257,56 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired("data", data), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, + ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1183,40 +1324,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() + inline.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1231,9 +1371,11 @@ private constructor( companion object { - @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic + fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic + fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1249,86 +1391,65 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle - @JsonCreator - private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = - JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Bundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = - Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1349,7 +1470,9 @@ private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1365,18 +1488,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Bundle = apply { - if (validated) { - return@apply - } + fun validate(): Bundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1386,6 +1510,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() @@ -1393,7 +1518,8 @@ private constructor( * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1404,40 +1530,38 @@ private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = + apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = - location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = + apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = - location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = - location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1451,11 +1575,17 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1463,44 +1593,57 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1514,25 +1657,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE + BUNDLE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { BUNDLE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1540,8 +1681,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1552,11 +1693,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1567,23 +1708,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1592,11 +1730,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1605,41 +1743,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Inline @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1647,16 +1779,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Inline = apply { - if (validated) { - return@apply - } + fun validate(): Inline = + apply { + if (validated) { + return@apply + } - code() - runtimeContext().validate() - type() - validated = true - } + code() + runtimeContext().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1666,13 +1799,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: + * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1681,31 +1816,37 @@ private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = + apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1713,44 +1854,47 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired("code", code), - checkRequired("runtimeContext", runtimeContext), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "runtimeContext", runtimeContext + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1771,31 +1915,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [RuntimeContext]. + * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1803,28 +1949,29 @@ private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = - runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = + apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1832,41 +1979,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1887,33 +2043,29 @@ private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] can contain an unknown value in a couple of cases: + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. * - * An instance of [Runtime] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1925,42 +2077,36 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value - * is a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") } /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1969,11 +2115,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1982,21 +2128,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -2010,25 +2156,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE + INLINE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { INLINE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2036,8 +2180,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2048,11 +2192,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2063,23 +2207,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2088,11 +2229,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2101,13 +2242,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2117,7 +2259,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2128,23 +2271,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE + CODE, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { CODE, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2168,7 +2311,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2183,19 +2326,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2204,11 +2344,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2217,31 +2357,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2249,15 +2386,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2267,12 +2405,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -2283,52 +2423,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2338,7 +2495,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2349,23 +2507,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2389,7 +2547,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2404,19 +2562,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2425,11 +2580,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2438,27 +2593,26 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** JSON schema for the function's parameters and return type */ @NoAutoDetect - class FunctionSchema - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - private val parameters: JsonValue = JsonMissing.of(), + class FunctionSchema @JsonCreator private constructor( + @JsonProperty("parameters") @ExcludeMissing private val parameters: JsonValue = JsonMissing.of(), @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonValue = parameters - @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns + @JsonProperty("returns") + @ExcludeMissing + fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing @@ -2466,20 +2620,22 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionSchema = apply { - if (validated) { - return@apply - } + fun validate(): FunctionSchema = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionSchema]. */ @@ -2490,45 +2646,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionSchema: FunctionSchema) = apply { - parameters = functionSchema.parameters - returns = functionSchema.returns - additionalProperties = functionSchema.additionalProperties.toMutableMap() - } + internal fun from(functionSchema: FunctionSchema) = + apply { + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() + } - fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } + fun parameters(parameters: JsonValue) = + apply { + this.parameters = parameters + } - fun returns(returns: JsonValue) = apply { this.returns = returns } + fun returns(returns: JsonValue) = + apply { + this.returns = returns + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionSchema = - FunctionSchema(parameters, returns, additionalProperties.toImmutable()) + FunctionSchema( + parameters, + returns, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2537,22 +2711,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2576,12 +2752,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2590,17 +2769,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2614,11 +2794,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2632,23 +2812,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2657,20 +2834,12 @@ private constructor( } @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("internal") - @ExcludeMissing - private val internal_: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Origin @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Id of the object the function is originating from */ @@ -2680,13 +2849,15 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -2694,10 +2865,12 @@ private constructor( fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ + @JsonProperty("internal") + @ExcludeMissing + fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing @@ -2705,16 +2878,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - internal_() - validated = true - } + objectId() + objectType() + internal_() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2724,12 +2898,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -2741,92 +2917,114 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - objectId = origin.objectId - objectType = origin.objectType - internal_ = origin.internal_ - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() + } /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } + fun internal_(internal_: JsonField) = + apply { + this.internal_ = internal_ + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - internal_, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + internal_, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2874,9 +3072,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2902,8 +3102,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2928,7 +3128,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2952,20 +3152,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2974,11 +3171,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2987,20 +3184,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index a1ec37a0..f0fc93e6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a function object by its id */ -class FunctionRetrieveParams -private constructor( +class FunctionRetrieveParams private constructor( private val functionId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Function id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionRetrieveParams]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionRetrieveParams: FunctionRetrieveParams) = apply { - functionId = functionRetrieveParams.functionId - additionalHeaders = functionRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = functionRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(functionRetrieveParams: FunctionRetrieveParams) = + apply { + functionId = functionRetrieveParams.functionId + additionalHeaders = functionRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = functionRetrieveParams.additionalQueryParams.toBuilder() + } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = + apply { + this.functionId = functionId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionRetrieveParams = FunctionRetrieveParams( - checkRequired("functionId", functionId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "functionId", functionId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionRetrieveParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionRetrieveParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index d052b992..d12ed9e3 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,55 +84,41 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_data") - @ExcludeMissing - private val functionData: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun functionData(): Optional = - Optional.ofNullable(functionData.getNullable("function_data")) + fun functionData(): Optional = Optional.ofNullable(functionData.getNullable("function_data")) /** Name of the prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -147,7 +133,9 @@ private constructor( fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -155,7 +143,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -163,25 +153,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - description() - functionData().ifPresent { it.validate() } - name() - promptData().ifPresent { it.validate() } - tags() - validated = true - } + description() + functionData().ifPresent { it.validate() } + name() + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -195,14 +187,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - description = body.description - functionData = body.functionData - name = body.name - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + description = body.description + functionData = body.functionData + name = body.name + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -211,26 +204,25 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = + apply { + this.functionData = functionData + } - fun functionData(prompt: FunctionData.Prompt) = - functionData(FunctionData.ofPrompt(prompt)) + fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) - fun functionData(global: FunctionData.Global) = - functionData(FunctionData.ofGlobal(global)) + fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) - fun functionData(nullableVariant: FunctionData.NullableVariant) = - functionData(FunctionData.ofNullableVariant(nullableVariant)) + fun functionData(nullableVariant: FunctionData.NullableVariant) = functionData(FunctionData.ofNullableVariant(nullableVariant)) /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -239,7 +231,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -248,9 +243,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -259,52 +255,62 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - description, - functionData, - name, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + description, + functionData, + name, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -313,8 +319,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -322,14 +327,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionUpdateParams]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionUpdateParams]. */ @@ -342,206 +350,287 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionUpdateParams: FunctionUpdateParams) = apply { - functionId = functionUpdateParams.functionId - body = functionUpdateParams.body.toBuilder() - additionalHeaders = functionUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = functionUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(functionUpdateParams: FunctionUpdateParams) = + apply { + functionId = functionUpdateParams.functionId + body = functionUpdateParams.body.toBuilder() + additionalHeaders = functionUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = functionUpdateParams.additionalQueryParams.toBuilder() + } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = + apply { + this.functionId = functionId + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + fun functionData(functionData: FunctionData) = + apply { + body.functionData(functionData) + } - fun functionData(functionData: JsonField) = apply { - body.functionData(functionData) - } + fun functionData(functionData: JsonField) = + apply { + body.functionData(functionData) + } - fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + fun functionData(prompt: FunctionData.Prompt) = + apply { + body.functionData(prompt) + } - fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + fun functionData(code: FunctionData.Code) = + apply { + body.functionData(code) + } - fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } + fun functionData(global: FunctionData.Global) = + apply { + body.functionData(global) + } - fun functionData(nullableVariant: FunctionData.NullableVariant) = apply { - body.functionData(nullableVariant) - } + fun functionData(nullableVariant: FunctionData.NullableVariant) = + apply { + body.functionData(nullableVariant) + } /** Name of the prompt */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the prompt */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionUpdateParams = FunctionUpdateParams( - checkRequired("functionId", functionId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "functionId", functionId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( + class FunctionData private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -571,50 +660,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global, nullableVariant) /* spotless:on */ @@ -631,20 +719,22 @@ private constructor( companion object { - @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic + fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic + fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic + fun ofGlobal(global: Global) = FunctionData(global = global) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - FunctionData(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = FunctionData(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [FunctionData] to a value of type - * [T]. + * An interface that defines how to map each variant of [FunctionData] to a value + * of type [T]. */ interface Visitor { @@ -659,76 +749,66 @@ private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(global = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(nullableVariant = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(global = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(nullableVariant = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize( - value: FunctionData, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Prompt @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -736,14 +816,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -753,11 +834,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -767,43 +850,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt(checkRequired("type", type), additionalProperties.toImmutable()) + Prompt( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -813,7 +910,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -824,23 +922,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT + PROMPT, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { PROMPT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -864,7 +962,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -879,19 +977,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -900,11 +995,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -913,31 +1008,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code - @JsonCreator - private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Code @JsonCreator private constructor( + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -945,15 +1037,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Code = apply { - if (validated) { - return@apply - } + fun validate(): Code = + apply { + if (validated) { + return@apply + } - data().validate() - type() - validated = true - } + data().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -963,12 +1056,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: + * * ```java * .data() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Code]. */ @@ -979,15 +1074,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = + apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -995,45 +1094,56 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired("data", data), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, + ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1051,40 +1161,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() - } - - override fun visitInline(inline: Inline) { - inline.validate() + bundle.validate() } - } - ) - validated = true - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun visitInline(inline: Inline) { + inline.validate() + } + }) + validated = true } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1099,9 +1208,11 @@ private constructor( companion object { - @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic + fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic + fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1117,86 +1228,65 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle - @JsonCreator - private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = - JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Bundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = - Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1217,7 +1307,9 @@ private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1233,18 +1325,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Bundle = apply { - if (validated) { - return@apply - } + fun validate(): Bundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1254,6 +1347,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() @@ -1261,7 +1355,8 @@ private constructor( * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1272,40 +1367,38 @@ private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = + apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = - location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = + apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = - location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = - location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1319,11 +1412,17 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1331,44 +1430,57 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1382,25 +1494,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE + BUNDLE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { BUNDLE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1408,8 +1518,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1420,11 +1530,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1435,23 +1545,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1460,11 +1567,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1473,41 +1580,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Inline @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1515,16 +1616,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Inline = apply { - if (validated) { - return@apply - } + fun validate(): Inline = + apply { + if (validated) { + return@apply + } - code() - runtimeContext().validate() - type() - validated = true - } + code() + runtimeContext().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1534,13 +1636,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: + * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1549,31 +1653,37 @@ private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = + apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1581,44 +1691,47 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired("code", code), - checkRequired("runtimeContext", runtimeContext), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "runtimeContext", runtimeContext + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1639,31 +1752,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [RuntimeContext]. + * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1671,28 +1786,29 @@ private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = - runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = + apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1700,41 +1816,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1755,33 +1880,29 @@ private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] can contain an unknown value in a couple of cases: + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. * - * An instance of [Runtime] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1793,42 +1914,36 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value - * is a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") } /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1837,11 +1952,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is 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 */ @@ -1850,21 +1965,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1878,25 +1993,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE + INLINE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { INLINE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1904,8 +2017,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1916,11 +2029,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1931,23 +2044,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1956,11 +2066,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1969,13 +2079,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1985,7 +2096,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1996,23 +2108,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE + CODE, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { CODE, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2036,7 +2148,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2051,19 +2163,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2072,11 +2181,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2085,31 +2194,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2117,15 +2223,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2135,12 +2242,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -2151,52 +2260,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2206,7 +2332,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2217,23 +2344,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2257,7 +2384,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2272,19 +2399,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2293,11 +2417,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2306,16 +2430,13 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -2324,20 +2445,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -2346,41 +2469,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2394,15 +2522,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionUpdateParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionUpdateParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index 2dc72265..c7fbe0c4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -23,34 +23,22 @@ import kotlin.jvm.optionals.getOrNull /** * A group is a collection of users which can be assigned an ACL * - * Groups can consist of individual users, as well as a set of groups they inherit from + * Groups can consist of individual users, as well as a set of groups they inherit + * from */ @NoAutoDetect -class Group -@JsonCreator -private constructor( +class Group @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_groups") - @ExcludeMissing - private val memberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("member_users") - @ExcludeMissing - private val memberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") @ExcludeMissing private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") @ExcludeMissing private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the group */ @@ -70,44 +58,48 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of group deletion, or null if the group is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the group */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(): Optional> = - Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = - Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) /** Identifies the user who created the group */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the group */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** * Unique id for the organization that the group belongs under * * It is forbidden to change the org after creating a group */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Date of group creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of group deletion, or null if the group is still active */ @JsonProperty("deleted_at") @@ -115,13 +107,15 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the group */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -133,7 +127,9 @@ private constructor( fun _memberUsers(): JsonField> = memberUsers /** Identifies the user who created the group */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -141,23 +137,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Group = apply { - if (validated) { - return@apply + fun validate(): Group = + apply { + if (validated) { + return@apply + } + + id() + name() + orgId() + created() + deletedAt() + description() + memberGroups() + memberUsers() + userId() + validated = true } - id() - name() - orgId() - created() - deletedAt() - description() - memberGroups() - memberUsers() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -166,13 +163,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Group]. * * The following fields are required: + * * ```java * .id() * .name() * .orgId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Group]. */ @@ -190,30 +189,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(group: Group) = apply { - id = group.id - name = group.name - orgId = group.orgId - created = group.created - deletedAt = group.deletedAt - description = group.description - memberGroups = group.memberGroups.map { it.toMutableList() } - memberUsers = group.memberUsers.map { it.toMutableList() } - userId = group.userId - additionalProperties = group.additionalProperties.toMutableMap() - } + internal fun from(group: Group) = + apply { + id = group.id + name = group.name + orgId = group.orgId + created = group.created + deletedAt = group.deletedAt + description = group.description + memberGroups = group.memberGroups.map { it.toMutableList() } + memberUsers = group.memberUsers.map { it.toMutableList() } + userId = group.userId + additionalProperties = group.additionalProperties.toMutableMap() + } /** Unique identifier for the group */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the group */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) /** Name of the group */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** * Unique id for the organization that the group belongs under @@ -227,7 +233,10 @@ private constructor( * * It is forbidden to change the org after creating a group */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Date of group creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -236,7 +245,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of group creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of group deletion, or null if the group is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -245,7 +257,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of group deletion, or null if the group is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -254,48 +269,50 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = - memberGroups(JsonField.ofNullable(memberGroups)) + fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - this.memberGroups = memberGroups.map { it.toMutableList() } - } + fun memberGroups(memberGroups: JsonField>) = + apply { + this.memberGroups = memberGroups.map { it.toMutableList() } + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { - memberGroups = - (memberGroups ?: JsonField.of(mutableListOf())).also { + fun addMemberGroup(memberGroup: String) = + apply { + memberGroups = (memberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("memberGroups", it).add(memberGroup) } - } + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) @@ -304,17 +321,18 @@ private constructor( fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - this.memberUsers = memberUsers.map { it.toMutableList() } - } + fun memberUsers(memberUsers: JsonField>) = + apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { - memberUsers = - (memberUsers ?: JsonField.of(mutableListOf())).also { + fun addMemberUser(memberUser: String) = + apply { + memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("memberUsers", it).add(memberUser) } - } + } /** Identifies the user who created the group */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -323,48 +341,64 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the group */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Group = Group( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("orgId", orgId), - created, - deletedAt, - description, - (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + created, + deletedAt, + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Group && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Group && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -373,6 +407,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Group{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Group{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 492a36c7..18dcc927 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -23,14 +23,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new group. If there is an existing group with the same name as the one specified in the - * request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one + * specified in the request, will return the existing group unmodified */ -class GroupCreateParams -private constructor( +class GroupCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the group */ @@ -42,8 +42,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ fun memberGroups(): Optional> = body.memberGroups() @@ -51,9 +51,9 @@ private constructor( fun memberUsers(): Optional> = body.memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(): Optional = body.orgName() @@ -66,8 +66,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ fun _memberGroups(): JsonField> = body._memberGroups() @@ -75,9 +75,9 @@ private constructor( fun _memberUsers(): JsonField> = body._memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -87,64 +87,52 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_groups") - @ExcludeMissing - private val memberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("member_users") - @ExcludeMissing - private val memberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") @ExcludeMissing private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") @ExcludeMissing private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the group */ fun name(): String = name.getRequired("name") /** Textual description of the group */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(): Optional> = - Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = - Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Textual description of the group */ @JsonProperty("description") @@ -154,8 +142,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -167,11 +155,13 @@ private constructor( fun _memberUsers(): JsonField> = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -179,19 +169,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + description() + memberGroups() + memberUsers() + orgName() + validated = true } - name() - description() - memberGroups() - memberUsers() - orgName() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -200,11 +191,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -218,20 +211,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - description = body.description - memberGroups = body.memberGroups.map { it.toMutableList() } - memberUsers = body.memberUsers.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + description = body.description + memberGroups = body.memberGroups.map { it.toMutableList() } + memberUsers = body.memberUsers.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) /** Name of the group */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -240,129 +237,140 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = - memberGroups(JsonField.ofNullable(memberGroups)) + fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - this.memberGroups = memberGroups.map { it.toMutableList() } - } + fun memberGroups(memberGroups: JsonField>) = + apply { + this.memberGroups = memberGroups.map { it.toMutableList() } + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { - memberGroups = - (memberGroups ?: JsonField.of(mutableListOf())).also { + fun addMemberGroup(memberGroup: String) = + apply { + memberGroups = (memberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("memberGroups", it).add(memberGroup) } - } + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = - memberUsers(JsonField.ofNullable(memberUsers)) + fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: Optional>) = - memberUsers(memberUsers.getOrNull()) + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - this.memberUsers = memberUsers.map { it.toMutableList() } - } + fun memberUsers(memberUsers: JsonField>) = + apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { - memberUsers = - (memberUsers ?: JsonField.of(mutableListOf())).also { + fun addMemberUser(memberUser: String) = + apply { + memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("memberUsers", it).add(memberUser) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - description, - (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -371,8 +379,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -383,11 +390,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupCreateParams]. */ @@ -399,232 +408,297 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupCreateParams: GroupCreateParams) = apply { - body = groupCreateParams.body.toBuilder() - additionalHeaders = groupCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = groupCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(groupCreateParams: GroupCreateParams) = + apply { + body = groupCreateParams.body.toBuilder() + additionalHeaders = groupCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = groupCreateParams.additionalQueryParams.toBuilder() + } /** Name of the group */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the group */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Textual description of the group */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the group */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + fun memberGroups(memberGroups: List?) = + apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - body.memberGroups(memberGroups) - } + fun memberGroups(memberGroups: JsonField>) = + apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } + fun addMemberGroup(memberGroup: String) = + apply { + body.addMemberGroup(memberGroup) + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } + fun memberUsers(memberUsers: List?) = + apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - body.memberUsers(memberUsers) - } + fun memberUsers(memberUsers: JsonField>) = + apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } + fun addMemberUser(memberUser: String) = + apply { + body.addMemberUser(memberUser) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupCreateParams = GroupCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 52f95360..4f981e03 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a group object by its id */ -class GroupDeleteParams -private constructor( +class GroupDeleteParams private constructor( private val groupId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Group id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupDeleteParams]. * * The following fields are required: + * * ```java * .groupId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupDeleteParams: GroupDeleteParams) = apply { - groupId = groupDeleteParams.groupId - additionalHeaders = groupDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = groupDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = groupDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(groupDeleteParams: GroupDeleteParams) = + apply { + groupId = groupDeleteParams.groupId + additionalHeaders = groupDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = groupDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = groupDeleteParams.additionalBodyProperties.toMutableMap() + } /** Group id */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = + apply { + this.groupId = groupId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): GroupDeleteParams = GroupDeleteParams( - checkRequired("groupId", groupId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "groupId", groupId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupDeleteParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupDeleteParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index b0123cdf..3b871286 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.GroupService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ -class GroupListPage -private constructor( +class GroupListPage private constructor( private val groupsService: GroupService, private val params: GroupListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupListPage && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is GroupListPage && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ - override fun toString() = - "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" + override fun toString() = "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(GroupListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(GroupListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { groupsService.list(it) } + return getNextPageParams().map { groupsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(groupsService: GroupService, params: GroupListParams, response: Response) = - GroupListPage(groupsService, params, response) + GroupListPage( + groupsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [GroupListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: GroupListPage) : Iterable { + class AutoPager( + private val firstPage: GroupListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index 5a17d75a..3f84e56e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.GroupServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ -class GroupListPageAsync -private constructor( +class GroupListPageAsync private constructor( private val groupsService: GroupServiceAsync, private val params: GroupListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupListPageAsync && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is GroupListPageAsync && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ - override fun toString() = - "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" + override fun toString() = "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(GroupListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(GroupListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { groupsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + groupsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(groupsService: GroupServiceAsync, params: GroupListParams, response: Response) = - GroupListPageAsync(groupsService, params, response) + GroupListPageAsync( + groupsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [GroupListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: GroupListPageAsync) { + class AutoPager( + private val firstPage: GroupListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Group) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Group) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index d63abcd7..df044bad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ -class GroupListParams -private constructor( +class GroupListParams private constructor( private val endingBefore: String?, private val groupName: String?, private val ids: Ids?, @@ -36,14 +35,15 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -51,8 +51,8 @@ private constructor( fun groupName(): Optional = Optional.ofNullable(groupName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,51 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.groupName?.let { queryParams.put("group_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.groupName?.let { + queryParams.put( + "group_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): GroupListParams = builder().build() + @JvmStatic + fun none(): GroupListParams = builder().build() /** Returns a mutable builder for constructing an instance of [GroupListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupListParams]. */ @@ -113,67 +139,80 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupListParams: GroupListParams) = apply { - endingBefore = groupListParams.endingBefore - groupName = groupListParams.groupName - ids = groupListParams.ids - limit = groupListParams.limit - orgName = groupListParams.orgName - startingAfter = groupListParams.startingAfter - additionalHeaders = groupListParams.additionalHeaders.toBuilder() - additionalQueryParams = groupListParams.additionalQueryParams.toBuilder() - } + internal fun from(groupListParams: GroupListParams) = + apply { + endingBefore = groupListParams.endingBefore + groupName = groupListParams.groupName + ids = groupListParams.ids + limit = groupListParams.limit + orgName = groupListParams.orgName + startingAfter = groupListParams.startingAfter + additionalHeaders = groupListParams.additionalHeaders.toBuilder() + additionalQueryParams = groupListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the group to search for */ - fun groupName(groupName: String?) = apply { this.groupName = groupName } + fun groupName(groupName: String?) = + apply { + this.groupName = groupName + } /** Name of the group to search for */ fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -182,7 +221,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -190,144 +232,172 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupListParams = GroupListParams( - endingBefore, - groupName, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + groupName, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -345,19 +415,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -372,12 +442,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -387,60 +462,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupListParams && endingBefore == other.endingBefore && groupName == other.groupName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupListParams && endingBefore == other.endingBefore && groupName == other.groupName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index add7d123..1a856148 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -23,14 +23,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace group. If there is an existing group with the same name as the one specified in - * the request, will replace the existing group with the provided fields + * Create or replace group. If there is an existing group with the same name as the + * one specified in the request, will replace the existing group with the provided + * fields */ -class GroupReplaceParams -private constructor( +class GroupReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the group */ @@ -42,8 +43,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ fun memberGroups(): Optional> = body.memberGroups() @@ -51,9 +52,9 @@ private constructor( fun memberUsers(): Optional> = body.memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(): Optional = body.orgName() @@ -66,8 +67,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ fun _memberGroups(): JsonField> = body._memberGroups() @@ -75,9 +76,9 @@ private constructor( fun _memberUsers(): JsonField> = body._memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -87,64 +88,52 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_groups") - @ExcludeMissing - private val memberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("member_users") - @ExcludeMissing - private val memberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") @ExcludeMissing private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") @ExcludeMissing private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the group */ fun name(): String = name.getRequired("name") /** Textual description of the group */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(): Optional> = - Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = - Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Textual description of the group */ @JsonProperty("description") @@ -154,8 +143,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -167,11 +156,13 @@ private constructor( fun _memberUsers(): JsonField> = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -179,19 +170,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + description() + memberGroups() + memberUsers() + orgName() + validated = true } - name() - description() - memberGroups() - memberUsers() - orgName() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -200,11 +192,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -218,20 +212,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - description = body.description - memberGroups = body.memberGroups.map { it.toMutableList() } - memberUsers = body.memberUsers.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + description = body.description + memberGroups = body.memberGroups.map { it.toMutableList() } + memberUsers = body.memberUsers.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) /** Name of the group */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -240,129 +238,140 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = - memberGroups(JsonField.ofNullable(memberGroups)) + fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - this.memberGroups = memberGroups.map { it.toMutableList() } - } + fun memberGroups(memberGroups: JsonField>) = + apply { + this.memberGroups = memberGroups.map { it.toMutableList() } + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { - memberGroups = - (memberGroups ?: JsonField.of(mutableListOf())).also { + fun addMemberGroup(memberGroup: String) = + apply { + memberGroups = (memberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("memberGroups", it).add(memberGroup) } - } + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = - memberUsers(JsonField.ofNullable(memberUsers)) + fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: Optional>) = - memberUsers(memberUsers.getOrNull()) + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - this.memberUsers = memberUsers.map { it.toMutableList() } - } + fun memberUsers(memberUsers: JsonField>) = + apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { - memberUsers = - (memberUsers ?: JsonField.of(mutableListOf())).also { + fun addMemberUser(memberUser: String) = + apply { + memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("memberUsers", it).add(memberUser) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - description, - (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -371,8 +380,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -383,11 +391,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupReplaceParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupReplaceParams]. */ @@ -399,232 +409,297 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupReplaceParams: GroupReplaceParams) = apply { - body = groupReplaceParams.body.toBuilder() - additionalHeaders = groupReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = groupReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(groupReplaceParams: GroupReplaceParams) = + apply { + body = groupReplaceParams.body.toBuilder() + additionalHeaders = groupReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = groupReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the group */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the group */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Textual description of the group */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the group */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + fun memberGroups(memberGroups: List?) = + apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - body.memberGroups(memberGroups) - } + fun memberGroups(memberGroups: JsonField>) = + apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } + fun addMemberGroup(memberGroup: String) = + apply { + body.addMemberGroup(memberGroup) + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } + fun memberUsers(memberUsers: List?) = + apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - body.memberUsers(memberUsers) - } + fun memberUsers(memberUsers: JsonField>) = + apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } + fun addMemberUser(memberUser: String) = + apply { + body.addMemberUser(memberUser) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupReplaceParams = GroupReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index a3aece35..9430bc01 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a group object by its id */ -class GroupRetrieveParams -private constructor( +class GroupRetrieveParams private constructor( private val groupId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Group id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,11 +43,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupRetrieveParams]. * * The following fields are required: + * * ```java * .groupId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupRetrieveParams]. */ @@ -59,131 +61,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupRetrieveParams: GroupRetrieveParams) = apply { - groupId = groupRetrieveParams.groupId - additionalHeaders = groupRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = groupRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(groupRetrieveParams: GroupRetrieveParams) = + apply { + groupId = groupRetrieveParams.groupId + additionalHeaders = groupRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = groupRetrieveParams.additionalQueryParams.toBuilder() + } /** Group id */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = + apply { + this.groupId = groupId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupRetrieveParams = GroupRetrieveParams( - checkRequired("groupId", groupId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "groupId", groupId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupRetrieveParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupRetrieveParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 5945b26a..20c8cdf6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -23,16 +23,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a group object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class GroupUpdateParams -private constructor( +class GroupUpdateParams private constructor( private val groupId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Group id */ @@ -80,67 +80,49 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("add_member_groups") - @ExcludeMissing - private val addMemberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("add_member_users") - @ExcludeMissing - private val addMemberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("remove_member_groups") - @ExcludeMissing - private val removeMemberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("remove_member_users") - @ExcludeMissing - private val removeMemberUsers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("add_member_groups") @ExcludeMissing private val addMemberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("add_member_users") @ExcludeMissing private val addMemberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("remove_member_groups") @ExcludeMissing private val removeMemberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("remove_member_users") @ExcludeMissing private val removeMemberUsers: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(): Optional> = - Optional.ofNullable(addMemberGroups.getNullable("add_member_groups")) + fun addMemberGroups(): Optional> = Optional.ofNullable(addMemberGroups.getNullable("add_member_groups")) /** A list of user IDs to add to the group */ - fun addMemberUsers(): Optional> = - Optional.ofNullable(addMemberUsers.getNullable("add_member_users")) + fun addMemberUsers(): Optional> = Optional.ofNullable(addMemberUsers.getNullable("add_member_users")) /** Textual description of the group */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the group */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(): Optional> = - Optional.ofNullable(removeMemberGroups.getNullable("remove_member_groups")) + fun removeMemberGroups(): Optional> = Optional.ofNullable(removeMemberGroups.getNullable("remove_member_groups")) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(): Optional> = - Optional.ofNullable(removeMemberUsers.getNullable("remove_member_users")) + fun removeMemberUsers(): Optional> = Optional.ofNullable(removeMemberUsers.getNullable("remove_member_users")) /** A list of group IDs to add to the group's inheriting-from set */ @JsonProperty("add_member_groups") @@ -158,7 +140,9 @@ private constructor( fun _description(): JsonField = description /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** A list of group IDs to remove from the group's inheriting-from set */ @JsonProperty("remove_member_groups") @@ -176,26 +160,28 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + addMemberGroups() + addMemberUsers() + description() + name() + removeMemberGroups() + removeMemberUsers() + validated = true } - addMemberGroups() - addMemberUsers() - description() - name() - removeMemberGroups() - removeMemberUsers() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -210,57 +196,56 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - addMemberGroups = body.addMemberGroups.map { it.toMutableList() } - addMemberUsers = body.addMemberUsers.map { it.toMutableList() } - description = body.description - name = body.name - removeMemberGroups = body.removeMemberGroups.map { it.toMutableList() } - removeMemberUsers = body.removeMemberUsers.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + addMemberGroups = body.addMemberGroups.map { it.toMutableList() } + addMemberUsers = body.addMemberUsers.map { it.toMutableList() } + description = body.description + name = body.name + removeMemberGroups = body.removeMemberGroups.map { it.toMutableList() } + removeMemberUsers = body.removeMemberUsers.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: List?) = - addMemberGroups(JsonField.ofNullable(addMemberGroups)) + fun addMemberGroups(addMemberGroups: List?) = addMemberGroups(JsonField.ofNullable(addMemberGroups)) /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: Optional>) = - addMemberGroups(addMemberGroups.getOrNull()) + fun addMemberGroups(addMemberGroups: Optional>) = addMemberGroups(addMemberGroups.getOrNull()) /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: JsonField>) = apply { - this.addMemberGroups = addMemberGroups.map { it.toMutableList() } - } + fun addMemberGroups(addMemberGroups: JsonField>) = + apply { + this.addMemberGroups = addMemberGroups.map { it.toMutableList() } + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addAddMemberGroup(addMemberGroup: String) = apply { - addMemberGroups = - (addMemberGroups ?: JsonField.of(mutableListOf())).also { + fun addAddMemberGroup(addMemberGroup: String) = + apply { + addMemberGroups = (addMemberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberGroups", it).add(addMemberGroup) } - } + } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: List?) = - addMemberUsers(JsonField.ofNullable(addMemberUsers)) + fun addMemberUsers(addMemberUsers: List?) = addMemberUsers(JsonField.ofNullable(addMemberUsers)) /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: Optional>) = - addMemberUsers(addMemberUsers.getOrNull()) + fun addMemberUsers(addMemberUsers: Optional>) = addMemberUsers(addMemberUsers.getOrNull()) /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: JsonField>) = apply { - this.addMemberUsers = addMemberUsers.map { it.toMutableList() } - } + fun addMemberUsers(addMemberUsers: JsonField>) = + apply { + this.addMemberUsers = addMemberUsers.map { it.toMutableList() } + } /** A list of user IDs to add to the group */ - fun addAddMemberUser(addMemberUser: String) = apply { - addMemberUsers = - (addMemberUsers ?: JsonField.of(mutableListOf())).also { + fun addAddMemberUser(addMemberUser: String) = + apply { + addMemberUsers = (addMemberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberUsers", it).add(addMemberUser) } - } + } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -269,9 +254,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the group */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -280,87 +266,95 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the group */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: List?) = - removeMemberGroups(JsonField.ofNullable(removeMemberGroups)) + fun removeMemberGroups(removeMemberGroups: List?) = removeMemberGroups(JsonField.ofNullable(removeMemberGroups)) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: Optional>) = - removeMemberGroups(removeMemberGroups.getOrNull()) + fun removeMemberGroups(removeMemberGroups: Optional>) = removeMemberGroups(removeMemberGroups.getOrNull()) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { - this.removeMemberGroups = removeMemberGroups.map { it.toMutableList() } - } + fun removeMemberGroups(removeMemberGroups: JsonField>) = + apply { + this.removeMemberGroups = removeMemberGroups.map { it.toMutableList() } + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun addRemoveMemberGroup(removeMemberGroup: String) = apply { - removeMemberGroups = - (removeMemberGroups ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberGroup(removeMemberGroup: String) = + apply { + removeMemberGroups = (removeMemberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberGroups", it).add(removeMemberGroup) } - } + } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: List?) = - removeMemberUsers(JsonField.ofNullable(removeMemberUsers)) + fun removeMemberUsers(removeMemberUsers: List?) = removeMemberUsers(JsonField.ofNullable(removeMemberUsers)) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: Optional>) = - removeMemberUsers(removeMemberUsers.getOrNull()) + fun removeMemberUsers(removeMemberUsers: Optional>) = removeMemberUsers(removeMemberUsers.getOrNull()) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { - this.removeMemberUsers = removeMemberUsers.map { it.toMutableList() } - } + fun removeMemberUsers(removeMemberUsers: JsonField>) = + apply { + this.removeMemberUsers = removeMemberUsers.map { it.toMutableList() } + } /** A list of user IDs to remove from the group */ - fun addRemoveMemberUser(removeMemberUser: String) = apply { - removeMemberUsers = - (removeMemberUsers ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberUser(removeMemberUser: String) = + apply { + removeMemberUsers = (removeMemberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberUsers", it).add(removeMemberUser) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - (addMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (addMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - description, - name, - (removeMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (removeMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (addMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (addMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + description, + name, + (removeMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (removeMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -369,8 +363,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" + override fun toString() = "Body{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -381,11 +374,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupUpdateParams]. * * The following fields are required: + * * ```java * .groupId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupUpdateParams]. */ @@ -398,244 +393,305 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupUpdateParams: GroupUpdateParams) = apply { - groupId = groupUpdateParams.groupId - body = groupUpdateParams.body.toBuilder() - additionalHeaders = groupUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = groupUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(groupUpdateParams: GroupUpdateParams) = + apply { + groupId = groupUpdateParams.groupId + body = groupUpdateParams.body.toBuilder() + additionalHeaders = groupUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = groupUpdateParams.additionalQueryParams.toBuilder() + } /** Group id */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = + apply { + this.groupId = groupId + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: List?) = apply { - body.addMemberGroups(addMemberGroups) - } + fun addMemberGroups(addMemberGroups: List?) = + apply { + body.addMemberGroups(addMemberGroups) + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: Optional>) = - addMemberGroups(addMemberGroups.getOrNull()) + fun addMemberGroups(addMemberGroups: Optional>) = addMemberGroups(addMemberGroups.getOrNull()) /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: JsonField>) = apply { - body.addMemberGroups(addMemberGroups) - } + fun addMemberGroups(addMemberGroups: JsonField>) = + apply { + body.addMemberGroups(addMemberGroups) + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addAddMemberGroup(addMemberGroup: String) = apply { - body.addAddMemberGroup(addMemberGroup) - } + fun addAddMemberGroup(addMemberGroup: String) = + apply { + body.addAddMemberGroup(addMemberGroup) + } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: List?) = apply { - body.addMemberUsers(addMemberUsers) - } + fun addMemberUsers(addMemberUsers: List?) = + apply { + body.addMemberUsers(addMemberUsers) + } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: Optional>) = - addMemberUsers(addMemberUsers.getOrNull()) + fun addMemberUsers(addMemberUsers: Optional>) = addMemberUsers(addMemberUsers.getOrNull()) /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: JsonField>) = apply { - body.addMemberUsers(addMemberUsers) - } + fun addMemberUsers(addMemberUsers: JsonField>) = + apply { + body.addMemberUsers(addMemberUsers) + } /** A list of user IDs to add to the group */ - fun addAddMemberUser(addMemberUser: String) = apply { body.addAddMemberUser(addMemberUser) } + fun addAddMemberUser(addMemberUser: String) = + apply { + body.addAddMemberUser(addMemberUser) + } /** Textual description of the group */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the group */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the group */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the group */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the group */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: List?) = apply { - body.removeMemberGroups(removeMemberGroups) - } + fun removeMemberGroups(removeMemberGroups: List?) = + apply { + body.removeMemberGroups(removeMemberGroups) + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: Optional>) = - removeMemberGroups(removeMemberGroups.getOrNull()) + fun removeMemberGroups(removeMemberGroups: Optional>) = removeMemberGroups(removeMemberGroups.getOrNull()) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { - body.removeMemberGroups(removeMemberGroups) - } + fun removeMemberGroups(removeMemberGroups: JsonField>) = + apply { + body.removeMemberGroups(removeMemberGroups) + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun addRemoveMemberGroup(removeMemberGroup: String) = apply { - body.addRemoveMemberGroup(removeMemberGroup) - } + fun addRemoveMemberGroup(removeMemberGroup: String) = + apply { + body.addRemoveMemberGroup(removeMemberGroup) + } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: List?) = apply { - body.removeMemberUsers(removeMemberUsers) - } + fun removeMemberUsers(removeMemberUsers: List?) = + apply { + body.removeMemberUsers(removeMemberUsers) + } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: Optional>) = - removeMemberUsers(removeMemberUsers.getOrNull()) + fun removeMemberUsers(removeMemberUsers: Optional>) = removeMemberUsers(removeMemberUsers.getOrNull()) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { - body.removeMemberUsers(removeMemberUsers) - } + fun removeMemberUsers(removeMemberUsers: JsonField>) = + apply { + body.removeMemberUsers(removeMemberUsers) + } /** A list of user IDs to remove from the group */ - fun addRemoveMemberUser(removeMemberUser: String) = apply { - body.addRemoveMemberUser(removeMemberUser) - } + fun addRemoveMemberUser(removeMemberUser: String) = + apply { + body.addRemoveMemberUser(removeMemberUser) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupUpdateParams = GroupUpdateParams( - checkRequired("groupId", groupId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "groupId", groupId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupUpdateParams{groupId=$groupId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupUpdateParams{groupId=$groupId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index c726e52b..ea8bc1c4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -21,99 +21,81 @@ import kotlin.jvm.optionals.getOrNull /** A dataset event */ @NoAutoDetect -class InsertDatasetEvent -@JsonCreator -private constructor( +class InsertDatasetEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_is_merge") - @ExcludeMissing - private val _isMerge: JsonField = JsonMissing.of(), - @JsonProperty("_merge_paths") - @ExcludeMissing - private val _mergePaths: JsonField>> = JsonMissing.of(), - @JsonProperty("_object_delete") - @ExcludeMissing - private val _objectDelete: JsonField = JsonMissing.of(), - @JsonProperty("_parent_id") - @ExcludeMissing - private val _parentId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") @ExcludeMissing private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") @ExcludeMissing private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") @ExcludeMissing private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") @ExcludeMissing private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -123,203 +105,234 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable + * object) + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId + @JsonProperty("_parent_id") + @ExcludeMissing + fun __parentId(): JsonField = _parentId /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -328,7 +341,9 @@ private constructor( fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -336,31 +351,33 @@ private constructor( private var validated: Boolean = false - fun validate(): InsertDatasetEvent = apply { - if (validated) { - return@apply - } + fun validate(): InsertDatasetEvent = + apply { + if (validated) { + return@apply + } - id() - _isMerge() - _mergePaths() - _objectDelete() - _parentId() - created() - metadata().ifPresent { it.validate() } - rootSpanId() - spanId() - spanParents() - tags() - validated = true - } + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + created() + metadata().ifPresent { it.validate() } + rootSpanId() + spanId() + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [InsertDatasetEvent]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InsertDatasetEvent]. */ @@ -382,241 +399,268 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertDatasetEvent: InsertDatasetEvent) = apply { - id = insertDatasetEvent.id - _isMerge = insertDatasetEvent._isMerge - _mergePaths = insertDatasetEvent._mergePaths.map { it.toMutableList() } - _objectDelete = insertDatasetEvent._objectDelete - _parentId = insertDatasetEvent._parentId - created = insertDatasetEvent.created - expected = insertDatasetEvent.expected - input = insertDatasetEvent.input - metadata = insertDatasetEvent.metadata - rootSpanId = insertDatasetEvent.rootSpanId - spanId = insertDatasetEvent.spanId - spanParents = insertDatasetEvent.spanParents.map { it.toMutableList() } - tags = insertDatasetEvent.tags.map { it.toMutableList() } - additionalProperties = insertDatasetEvent.additionalProperties.toMutableMap() - } + internal fun from(insertDatasetEvent: InsertDatasetEvent) = + apply { + id = insertDatasetEvent.id + _isMerge = insertDatasetEvent._isMerge + _mergePaths = insertDatasetEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertDatasetEvent._objectDelete + _parentId = insertDatasetEvent._parentId + created = insertDatasetEvent.created + expected = insertDatasetEvent.expected + input = insertDatasetEvent.input + metadata = insertDatasetEvent.metadata + rootSpanId = insertDatasetEvent.rootSpanId + spanId = insertDatasetEvent.spanId + spanParents = insertDatasetEvent.spanParents.map { it.toMutableList() } + tags = insertDatasetEvent.tags.map { it.toMutableList() } + additionalProperties = insertDatasetEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = + apply { + this._isMerge = _isMerge + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>?) = - _mergePaths(JsonField.ofNullable(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: Optional>>) = - _mergePaths(_mergePaths.getOrNull()) + fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths.map { it.toMutableList() } - } + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. + * + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: JsonField>>) = + apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ - fun addMergePath(mergePath: List) = apply { - _mergePaths = - (_mergePaths ?: JsonField.of(mutableListOf())).also { + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. + * + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. + */ + fun addMergePath(mergePath: List) = + apply { + _mergePaths = (_mergePaths ?: JsonField.of(mutableListOf())).also { checkKnown("_mergePaths", it).add(mergePath) } - } + } /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: Boolean?) = - _objectDelete(JsonField.ofNullable(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean?) = _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: Optional) = - _objectDelete(_objectDelete.getOrNull()) + fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } + fun _objectDelete(_objectDelete: JsonField) = + apply { + this._objectDelete = _objectDelete + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun _parentId(_parentId: JsonField) = + apply { + this._parentId = _parentId + } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -625,60 +669,73 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the dataset event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + * The argument that uniquely define an input case (an arbitrary, JSON serializable + * object) */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -686,18 +743,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -705,37 +762,40 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -743,18 +803,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -762,37 +822,40 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -800,18 +863,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -819,48 +882,49 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -869,66 +933,75 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertDatasetEvent = InsertDatasetEvent( - id, - _isMerge, - (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, - _objectDelete, - _parentId, - created, - expected, - input, - metadata, - rootSpanId, - spanId, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + created, + expected, + input, + metadata, + rootSpanId, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -937,20 +1010,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -959,38 +1034,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1003,11 +1086,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1016,6 +1099,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 099bcb9a..56212366 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -18,24 +18,25 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class InsertEventsResponse -@JsonCreator -private constructor( - @JsonProperty("row_ids") - @ExcludeMissing - private val rowIds: JsonField> = JsonMissing.of(), +class InsertEventsResponse @JsonCreator private constructor( + @JsonProperty("row_ids") @ExcludeMissing private val rowIds: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ fun rowIds(): List = rowIds.getRequired("row_ids") /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField> = rowIds + @JsonProperty("row_ids") + @ExcludeMissing + fun _rowIds(): JsonField> = rowIds @JsonAnyGetter @ExcludeMissing @@ -43,28 +44,32 @@ private constructor( private var validated: Boolean = false - fun validate(): InsertEventsResponse = apply { - if (validated) { - return@apply - } + fun validate(): InsertEventsResponse = + apply { + if (validated) { + return@apply + } - rowIds() - validated = true - } + rowIds() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [InsertEventsResponse]. + * Returns a mutable builder for constructing an instance of + * [InsertEventsResponse]. * * The following fields are required: + * * ```java * .rowIds() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InsertEventsResponse]. */ @@ -74,68 +79,78 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertEventsResponse: InsertEventsResponse) = apply { - rowIds = insertEventsResponse.rowIds.map { it.toMutableList() } - additionalProperties = insertEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(insertEventsResponse: InsertEventsResponse) = + apply { + rowIds = insertEventsResponse.rowIds.map { it.toMutableList() } + additionalProperties = insertEventsResponse.additionalProperties.toMutableMap() + } /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ - fun rowIds(rowIds: JsonField>) = apply { - this.rowIds = rowIds.map { it.toMutableList() } - } + fun rowIds(rowIds: JsonField>) = + apply { + this.rowIds = rowIds.map { it.toMutableList() } + } /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ - fun addRowId(rowId: String) = apply { - rowIds = - (rowIds ?: JsonField.of(mutableListOf())).also { + fun addRowId(rowId: String) = + apply { + rowIds = (rowIds ?: JsonField.of(mutableListOf())).also { checkKnown("rowIds", it).add(rowId) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertEventsResponse = InsertEventsResponse( - checkRequired("rowIds", rowIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "rowIds", rowIds + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertEventsResponse && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertEventsResponse && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -144,6 +159,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" + override fun toString() = "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 3b414e84..4f95c38c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -21,125 +21,98 @@ import kotlin.jvm.optionals.getOrNull /** An experiment event */ @NoAutoDetect -class InsertExperimentEvent -@JsonCreator -private constructor( +class InsertExperimentEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_is_merge") - @ExcludeMissing - private val _isMerge: JsonField = JsonMissing.of(), - @JsonProperty("_merge_paths") - @ExcludeMissing - private val _mergePaths: JsonField>> = JsonMissing.of(), - @JsonProperty("_object_delete") - @ExcludeMissing - private val _objectDelete: JsonField = JsonMissing.of(), - @JsonProperty("_parent_id") - @ExcludeMissing - private val _parentId: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - private val context: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") - @ExcludeMissing - private val datasetRecordId: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") @ExcludeMissing private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") @ExcludeMissing private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") @ExcludeMissing private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") @ExcludeMissing private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_record_id") @ExcludeMissing private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") - @ExcludeMissing - private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) @@ -147,254 +120,291 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error + @JsonProperty("error") + @ExcludeMissing + fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + @JsonProperty("output") + @ExcludeMissing + fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId + @JsonProperty("_parent_id") + @ExcludeMissing + fun __parentId(): JsonField = _parentId /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId(): JsonField = datasetRecordId /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -402,36 +412,40 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -440,7 +454,9 @@ private constructor( fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -448,36 +464,41 @@ private constructor( private var validated: Boolean = false - fun validate(): InsertExperimentEvent = apply { - if (validated) { - return@apply - } + fun validate(): InsertExperimentEvent = + apply { + if (validated) { + return@apply + } - id() - _isMerge() - _mergePaths() - _objectDelete() - _parentId() - context().ifPresent { it.validate() } - created() - datasetRecordId() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - rootSpanId() - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanId() - spanParents() - tags() - validated = true - } + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + context().ifPresent { it.validate() } + created() + datasetRecordId() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + rootSpanId() + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanId() + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [InsertExperimentEvent]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [InsertExperimentEvent]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [InsertExperimentEvent]. */ @@ -506,269 +527,302 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertExperimentEvent: InsertExperimentEvent) = apply { - id = insertExperimentEvent.id - _isMerge = insertExperimentEvent._isMerge - _mergePaths = insertExperimentEvent._mergePaths.map { it.toMutableList() } - _objectDelete = insertExperimentEvent._objectDelete - _parentId = insertExperimentEvent._parentId - context = insertExperimentEvent.context - created = insertExperimentEvent.created - datasetRecordId = insertExperimentEvent.datasetRecordId - error = insertExperimentEvent.error - expected = insertExperimentEvent.expected - input = insertExperimentEvent.input - metadata = insertExperimentEvent.metadata - metrics = insertExperimentEvent.metrics - output = insertExperimentEvent.output - rootSpanId = insertExperimentEvent.rootSpanId - scores = insertExperimentEvent.scores - spanAttributes = insertExperimentEvent.spanAttributes - spanId = insertExperimentEvent.spanId - spanParents = insertExperimentEvent.spanParents.map { it.toMutableList() } - tags = insertExperimentEvent.tags.map { it.toMutableList() } - additionalProperties = insertExperimentEvent.additionalProperties.toMutableMap() - } + internal fun from(insertExperimentEvent: InsertExperimentEvent) = + apply { + id = insertExperimentEvent.id + _isMerge = insertExperimentEvent._isMerge + _mergePaths = insertExperimentEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertExperimentEvent._objectDelete + _parentId = insertExperimentEvent._parentId + context = insertExperimentEvent.context + created = insertExperimentEvent.created + datasetRecordId = insertExperimentEvent.datasetRecordId + error = insertExperimentEvent.error + expected = insertExperimentEvent.expected + input = insertExperimentEvent.input + metadata = insertExperimentEvent.metadata + metrics = insertExperimentEvent.metrics + output = insertExperimentEvent.output + rootSpanId = insertExperimentEvent.rootSpanId + scores = insertExperimentEvent.scores + spanAttributes = insertExperimentEvent.spanAttributes + spanId = insertExperimentEvent.spanId + spanParents = insertExperimentEvent.spanParents.map { it.toMutableList() } + tags = insertExperimentEvent.tags.map { it.toMutableList() } + additionalProperties = insertExperimentEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = + apply { + this._isMerge = _isMerge + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>?) = - _mergePaths(JsonField.ofNullable(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: Optional>>) = - _mergePaths(_mergePaths.getOrNull()) + fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths.map { it.toMutableList() } - } + fun _mergePaths(_mergePaths: JsonField>>) = + apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun addMergePath(mergePath: List) = apply { - _mergePaths = - (_mergePaths ?: JsonField.of(mutableListOf())).also { + fun addMergePath(mergePath: List) = + apply { + _mergePaths = (_mergePaths ?: JsonField.of(mutableListOf())).also { checkKnown("_mergePaths", it).add(mergePath) } - } + } /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: Boolean?) = - _objectDelete(JsonField.ofNullable(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean?) = _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: Optional) = - _objectDelete(_objectDelete.getOrNull()) + fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } + fun _objectDelete(_objectDelete: JsonField) = + apply { + this._objectDelete = _objectDelete + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun _parentId(_parentId: JsonField) = + apply { + this._parentId = _parentId + } /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = + apply { + this.context = context + } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -777,122 +831,144 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the experiment event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String?) = - datasetRecordId(JsonField.ofNullable(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String?) = datasetRecordId(JsonField.ofNullable(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.getOrNull()) + fun datasetRecordId(datasetRecordId: Optional) = datasetRecordId(datasetRecordId.getOrNull()) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } + fun datasetRecordId(datasetRecordId: JsonField) = + apply { + this.datasetRecordId = datasetRecordId + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = + apply { + this.error = error + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = + apply { + this.output = output + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -900,18 +976,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -919,83 +995,91 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = - spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = + apply { + this.spanAttributes = spanAttributes + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1003,18 +1087,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1022,37 +1106,40 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1060,18 +1147,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1079,48 +1166,49 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -1129,93 +1217,94 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertExperimentEvent = InsertExperimentEvent( - id, - _isMerge, - (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, - _objectDelete, - _parentId, - context, - created, - datasetRecordId, - error, - expected, - input, - metadata, - metrics, - output, - rootSpanId, - scores, - spanAttributes, - spanId, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + context, + created, + datasetRecordId, + error, + expected, + input, + metadata, + metrics, + output, + rootSpanId, + scores, + spanAttributes, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ @NoAutoDetect - class Context - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Context @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -1238,23 +1327,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Context = apply { - if (validated) { - return@apply - } + fun validate(): Context = + apply { + if (validated) { + return@apply + } - callerFilename() - callerFunctionname() - callerLineno() - validated = true - } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Context]. */ @@ -1266,38 +1357,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = + apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String?) = - callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = + apply { + this.callerFilename = callerFilename + } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String?) = - callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = + apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -1309,44 +1399,52 @@ private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = + apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1355,23 +1453,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1380,20 +1475,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1402,38 +1499,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1446,38 +1551,22 @@ private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - private val completionTokens: JsonField = JsonMissing.of(), + class Metrics @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") - @ExcludeMissing - private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") - @ExcludeMissing - private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** This metric is deprecated */ @@ -1491,31 +1580,31 @@ private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1523,35 +1612,41 @@ private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ - @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end + @JsonProperty("end") + @ExcludeMissing + fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ - @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + @JsonProperty("start") + @ExcludeMissing + fun _start(): JsonField = start /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1559,25 +1654,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true - } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1594,133 +1691,144 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = + apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = + apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = + apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun callerLineno(callerLineno: JsonValue) = + apply { + this.callerLineno = callerLineno + } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long?) = - completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long) = - completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = + apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ - fun end(end: JsonField) = apply { this.end = end } + fun end(end: JsonField) = + apply { + this.end = end + } /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = + apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = + apply { + this.start = start + } /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1732,47 +1840,57 @@ private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = + apply { + this.tokens = tokens + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1781,25 +1899,23 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1808,20 +1924,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1830,38 +1948,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1874,11 +2000,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1887,6 +2013,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index abf02697..0d2bd5ff 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -21,122 +21,97 @@ import kotlin.jvm.optionals.getOrNull /** A project logs event */ @NoAutoDetect -class InsertProjectLogsEvent -@JsonCreator -private constructor( +class InsertProjectLogsEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_is_merge") - @ExcludeMissing - private val _isMerge: JsonField = JsonMissing.of(), - @JsonProperty("_merge_paths") - @ExcludeMissing - private val _mergePaths: JsonField>> = JsonMissing.of(), - @JsonProperty("_object_delete") - @ExcludeMissing - private val _objectDelete: JsonField = JsonMissing.of(), - @JsonProperty("_parent_id") - @ExcludeMissing - private val _parentId: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - private val context: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") @ExcludeMissing private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") @ExcludeMissing private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") @ExcludeMissing private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") @ExcludeMissing private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") - @ExcludeMissing - private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) @@ -144,234 +119,273 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error + @JsonProperty("error") + @ExcludeMissing + fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + @JsonProperty("output") + @ExcludeMissing + fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId + @JsonProperty("_parent_id") + @ExcludeMissing + fun __parentId(): JsonField = _parentId /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -379,36 +393,40 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -417,7 +435,9 @@ private constructor( fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -425,35 +445,40 @@ private constructor( private var validated: Boolean = false - fun validate(): InsertProjectLogsEvent = apply { - if (validated) { - return@apply - } + fun validate(): InsertProjectLogsEvent = + apply { + if (validated) { + return@apply + } - id() - _isMerge() - _mergePaths() - _objectDelete() - _parentId() - context().ifPresent { it.validate() } - created() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - rootSpanId() - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanId() - spanParents() - tags() - validated = true - } + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + context().ifPresent { it.validate() } + created() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + rootSpanId() + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanId() + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [InsertProjectLogsEvent]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [InsertProjectLogsEvent]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [InsertProjectLogsEvent]. */ @@ -481,268 +506,301 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertProjectLogsEvent: InsertProjectLogsEvent) = apply { - id = insertProjectLogsEvent.id - _isMerge = insertProjectLogsEvent._isMerge - _mergePaths = insertProjectLogsEvent._mergePaths.map { it.toMutableList() } - _objectDelete = insertProjectLogsEvent._objectDelete - _parentId = insertProjectLogsEvent._parentId - context = insertProjectLogsEvent.context - created = insertProjectLogsEvent.created - error = insertProjectLogsEvent.error - expected = insertProjectLogsEvent.expected - input = insertProjectLogsEvent.input - metadata = insertProjectLogsEvent.metadata - metrics = insertProjectLogsEvent.metrics - output = insertProjectLogsEvent.output - rootSpanId = insertProjectLogsEvent.rootSpanId - scores = insertProjectLogsEvent.scores - spanAttributes = insertProjectLogsEvent.spanAttributes - spanId = insertProjectLogsEvent.spanId - spanParents = insertProjectLogsEvent.spanParents.map { it.toMutableList() } - tags = insertProjectLogsEvent.tags.map { it.toMutableList() } - additionalProperties = insertProjectLogsEvent.additionalProperties.toMutableMap() - } + internal fun from(insertProjectLogsEvent: InsertProjectLogsEvent) = + apply { + id = insertProjectLogsEvent.id + _isMerge = insertProjectLogsEvent._isMerge + _mergePaths = insertProjectLogsEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertProjectLogsEvent._objectDelete + _parentId = insertProjectLogsEvent._parentId + context = insertProjectLogsEvent.context + created = insertProjectLogsEvent.created + error = insertProjectLogsEvent.error + expected = insertProjectLogsEvent.expected + input = insertProjectLogsEvent.input + metadata = insertProjectLogsEvent.metadata + metrics = insertProjectLogsEvent.metrics + output = insertProjectLogsEvent.output + rootSpanId = insertProjectLogsEvent.rootSpanId + scores = insertProjectLogsEvent.scores + spanAttributes = insertProjectLogsEvent.spanAttributes + spanId = insertProjectLogsEvent.spanId + spanParents = insertProjectLogsEvent.spanParents.map { it.toMutableList() } + tags = insertProjectLogsEvent.tags.map { it.toMutableList() } + additionalProperties = insertProjectLogsEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = + apply { + this._isMerge = _isMerge + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>?) = - _mergePaths(JsonField.ofNullable(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: Optional>>) = - _mergePaths(_mergePaths.getOrNull()) + fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths.map { it.toMutableList() } - } + fun _mergePaths(_mergePaths: JsonField>>) = + apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun addMergePath(mergePath: List) = apply { - _mergePaths = - (_mergePaths ?: JsonField.of(mutableListOf())).also { + fun addMergePath(mergePath: List) = + apply { + _mergePaths = (_mergePaths ?: JsonField.of(mutableListOf())).also { checkKnown("_mergePaths", it).add(mergePath) } - } + } /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: Boolean?) = - _objectDelete(JsonField.ofNullable(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean?) = _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: Optional) = - _objectDelete(_objectDelete.getOrNull()) + fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } + fun _objectDelete(_objectDelete: JsonField) = + apply { + this._objectDelete = _objectDelete + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun _parentId(_parentId: JsonField) = + apply { + this._parentId = _parentId + } /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = + apply { + this.context = context + } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -751,97 +809,119 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the project logs event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = + apply { + this.error = error + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = + apply { + this.output = output + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -849,18 +929,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -868,83 +948,91 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = - spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = + apply { + this.spanAttributes = spanAttributes + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -952,18 +1040,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -971,37 +1059,40 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1009,18 +1100,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1028,48 +1119,49 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -1078,92 +1170,93 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertProjectLogsEvent = InsertProjectLogsEvent( - id, - _isMerge, - (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, - _objectDelete, - _parentId, - context, - created, - error, - expected, - input, - metadata, - metrics, - output, - rootSpanId, - scores, - spanAttributes, - spanId, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + context, + created, + error, + expected, + input, + metadata, + metrics, + output, + rootSpanId, + scores, + spanAttributes, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ @NoAutoDetect - class Context - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Context @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -1186,23 +1279,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Context = apply { - if (validated) { - return@apply - } + fun validate(): Context = + apply { + if (validated) { + return@apply + } - callerFilename() - callerFunctionname() - callerLineno() - validated = true - } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Context]. */ @@ -1214,38 +1309,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = + apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String?) = - callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = + apply { + this.callerFilename = callerFilename + } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String?) = - callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = + apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -1257,44 +1351,52 @@ private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = + apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1303,23 +1405,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1328,20 +1427,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1350,38 +1451,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1394,38 +1503,22 @@ private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - private val completionTokens: JsonField = JsonMissing.of(), + class Metrics @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") - @ExcludeMissing - private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") - @ExcludeMissing - private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** This metric is deprecated */ @@ -1439,31 +1532,31 @@ private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1471,35 +1564,41 @@ private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ - @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end + @JsonProperty("end") + @ExcludeMissing + fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ - @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + @JsonProperty("start") + @ExcludeMissing + fun _start(): JsonField = start /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1507,25 +1606,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true - } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1542,133 +1643,144 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = + apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = + apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = + apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun callerLineno(callerLineno: JsonValue) = + apply { + this.callerLineno = callerLineno + } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long?) = - completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long) = - completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = + apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ - fun end(end: JsonField) = apply { this.end = end } + fun end(end: JsonField) = + apply { + this.end = end + } /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = + apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = + apply { + this.start = start + } /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1680,47 +1792,57 @@ private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = + apply { + this.tokens = tokens + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1729,25 +1851,23 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1756,20 +1876,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1778,38 +1900,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1822,11 +1952,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1835,6 +1965,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index a7fa4c4d..8c1b55dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -19,22 +19,15 @@ import java.util.Optional /** Summary of a metric's performance */ @NoAutoDetect -class MetricSummary -@JsonCreator -private constructor( - @JsonProperty("improvements") - @ExcludeMissing - private val improvements: JsonField = JsonMissing.of(), - @JsonProperty("metric") - @ExcludeMissing - private val metric: JsonField = JsonMissing.of(), +class MetricSummary @JsonCreator private constructor( + @JsonProperty("improvements") @ExcludeMissing private val improvements: JsonField = JsonMissing.of(), + @JsonProperty("metric") @ExcludeMissing private val metric: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("regressions") - @ExcludeMissing - private val regressions: JsonField = JsonMissing.of(), + @JsonProperty("regressions") @ExcludeMissing private val regressions: JsonField = JsonMissing.of(), @JsonProperty("unit") @ExcludeMissing private val unit: JsonField = JsonMissing.of(), @JsonProperty("diff") @ExcludeMissing private val diff: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Number of improvements in the metric */ @@ -61,19 +54,29 @@ private constructor( fun _improvements(): JsonField = improvements /** Average metric across all examples */ - @JsonProperty("metric") @ExcludeMissing fun _metric(): JsonField = metric + @JsonProperty("metric") + @ExcludeMissing + fun _metric(): JsonField = metric /** Name of the metric */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Number of regressions in the metric */ - @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions + @JsonProperty("regressions") + @ExcludeMissing + fun _regressions(): JsonField = regressions /** Unit label for the metric */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + @JsonProperty("unit") + @ExcludeMissing + fun _unit(): JsonField = unit /** Difference in metric between the current and comparison experiment */ - @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff + @JsonProperty("diff") + @ExcludeMissing + fun _diff(): JsonField = diff @JsonAnyGetter @ExcludeMissing @@ -81,20 +84,21 @@ private constructor( private var validated: Boolean = false - fun validate(): MetricSummary = apply { - if (validated) { - return@apply + fun validate(): MetricSummary = + apply { + if (validated) { + return@apply + } + + improvements() + metric() + name() + regressions() + unit() + diff() + validated = true } - improvements() - metric() - name() - regressions() - unit() - diff() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -103,6 +107,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [MetricSummary]. * * The following fields are required: + * * ```java * .improvements() * .metric() @@ -111,7 +116,8 @@ private constructor( * .unit() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [MetricSummary]. */ @@ -126,89 +132,125 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metricSummary: MetricSummary) = apply { - improvements = metricSummary.improvements - metric = metricSummary.metric - name = metricSummary.name - regressions = metricSummary.regressions - unit = metricSummary.unit - diff = metricSummary.diff - additionalProperties = metricSummary.additionalProperties.toMutableMap() - } + internal fun from(metricSummary: MetricSummary) = + apply { + improvements = metricSummary.improvements + metric = metricSummary.metric + name = metricSummary.name + regressions = metricSummary.regressions + unit = metricSummary.unit + diff = metricSummary.diff + additionalProperties = metricSummary.additionalProperties.toMutableMap() + } /** Number of improvements in the metric */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) /** Number of improvements in the metric */ - fun improvements(improvements: JsonField) = apply { this.improvements = improvements } + fun improvements(improvements: JsonField) = + apply { + this.improvements = improvements + } /** Average metric across all examples */ fun metric(metric: Double) = metric(JsonField.of(metric)) /** Average metric across all examples */ - fun metric(metric: JsonField) = apply { this.metric = metric } + fun metric(metric: JsonField) = + apply { + this.metric = metric + } /** Name of the metric */ fun name(name: String) = name(JsonField.of(name)) /** Name of the metric */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Number of regressions in the metric */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) /** Number of regressions in the metric */ - fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + fun regressions(regressions: JsonField) = + apply { + this.regressions = regressions + } /** Unit label for the metric */ fun unit(unit: String) = unit(JsonField.of(unit)) /** Unit label for the metric */ - fun unit(unit: JsonField) = apply { this.unit = unit } + fun unit(unit: JsonField) = + apply { + this.unit = unit + } /** Difference in metric between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) /** Difference in metric between the current and comparison experiment */ - fun diff(diff: JsonField) = apply { this.diff = diff } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun diff(diff: JsonField) = + apply { + this.diff = diff + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MetricSummary = MetricSummary( - checkRequired("improvements", improvements), - checkRequired("metric", metric), - checkRequired("name", name), - checkRequired("regressions", regressions), - checkRequired("unit", unit), - diff, - additionalProperties.toImmutable(), + checkRequired( + "improvements", improvements + ), + checkRequired( + "metric", metric + ), + checkRequired( + "name", name + ), + checkRequired( + "regressions", regressions + ), + checkRequired( + "unit", unit + ), + diff, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MetricSummary && improvements == other.improvements && metric == other.metric && name == other.name && regressions == other.regressions && unit == other.unit && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MetricSummary && improvements == other.improvements && metric == other.metric && name == other.name && regressions == other.regressions && unit == other.unit && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -217,6 +259,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "MetricSummary{improvements=$improvements, metric=$metric, name=$name, regressions=$regressions, unit=$unit, diff=$diff, additionalProperties=$additionalProperties}" + override fun toString() = "MetricSummary{improvements=$improvements, metric=$metric, name=$name, regressions=$regressions, unit=$unit, diff=$diff, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 6eb781e8..f88b718b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -32,22 +32,13 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class OnlineScoreConfig -@JsonCreator -private constructor( - @JsonProperty("sampling_rate") - @ExcludeMissing - private val samplingRate: JsonField = JsonMissing.of(), - @JsonProperty("scorers") - @ExcludeMissing - private val scorers: JsonField> = JsonMissing.of(), - @JsonProperty("apply_to_root_span") - @ExcludeMissing - private val applyToRootSpan: JsonField = JsonMissing.of(), - @JsonProperty("apply_to_span_names") - @ExcludeMissing - private val applyToSpanNames: JsonField> = JsonMissing.of(), +class OnlineScoreConfig @JsonCreator private constructor( + @JsonProperty("sampling_rate") @ExcludeMissing private val samplingRate: JsonField = JsonMissing.of(), + @JsonProperty("scorers") @ExcludeMissing private val scorers: JsonField> = JsonMissing.of(), + @JsonProperty("apply_to_root_span") @ExcludeMissing private val applyToRootSpan: JsonField = JsonMissing.of(), + @JsonProperty("apply_to_span_names") @ExcludeMissing private val applyToSpanNames: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The sampling rate for online scoring */ @@ -57,12 +48,10 @@ private constructor( fun scorers(): List = scorers.getRequired("scorers") /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(): Optional = - Optional.ofNullable(applyToRootSpan.getNullable("apply_to_root_span")) + fun applyToRootSpan(): Optional = Optional.ofNullable(applyToRootSpan.getNullable("apply_to_root_span")) /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(): Optional> = - Optional.ofNullable(applyToSpanNames.getNullable("apply_to_span_names")) + fun applyToSpanNames(): Optional> = Optional.ofNullable(applyToSpanNames.getNullable("apply_to_span_names")) /** The sampling rate for online scoring */ @JsonProperty("sampling_rate") @@ -70,7 +59,9 @@ private constructor( fun _samplingRate(): JsonField = samplingRate /** The list of scorers to use for online scoring */ - @JsonProperty("scorers") @ExcludeMissing fun _scorers(): JsonField> = scorers + @JsonProperty("scorers") + @ExcludeMissing + fun _scorers(): JsonField> = scorers /** Whether to trigger online scoring on the root span of each trace */ @JsonProperty("apply_to_root_span") @@ -88,17 +79,18 @@ private constructor( private var validated: Boolean = false - fun validate(): OnlineScoreConfig = apply { - if (validated) { - return@apply - } + fun validate(): OnlineScoreConfig = + apply { + if (validated) { + return@apply + } - samplingRate() - scorers().forEach { it.validate() } - applyToRootSpan() - applyToSpanNames() - validated = true - } + samplingRate() + scorers().forEach { it.validate() } + applyToRootSpan() + applyToSpanNames() + validated = true + } fun toBuilder() = Builder().from(this) @@ -108,12 +100,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [OnlineScoreConfig]. * * The following fields are required: + * * ```java * .samplingRate() * .scorers() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OnlineScoreConfig]. */ @@ -126,37 +120,40 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(onlineScoreConfig: OnlineScoreConfig) = apply { - samplingRate = onlineScoreConfig.samplingRate - scorers = onlineScoreConfig.scorers.map { it.toMutableList() } - applyToRootSpan = onlineScoreConfig.applyToRootSpan - applyToSpanNames = onlineScoreConfig.applyToSpanNames.map { it.toMutableList() } - additionalProperties = onlineScoreConfig.additionalProperties.toMutableMap() - } + internal fun from(onlineScoreConfig: OnlineScoreConfig) = + apply { + samplingRate = onlineScoreConfig.samplingRate + scorers = onlineScoreConfig.scorers.map { it.toMutableList() } + applyToRootSpan = onlineScoreConfig.applyToRootSpan + applyToSpanNames = onlineScoreConfig.applyToSpanNames.map { it.toMutableList() } + additionalProperties = onlineScoreConfig.additionalProperties.toMutableMap() + } /** The sampling rate for online scoring */ fun samplingRate(samplingRate: Double) = samplingRate(JsonField.of(samplingRate)) /** The sampling rate for online scoring */ - fun samplingRate(samplingRate: JsonField) = apply { - this.samplingRate = samplingRate - } + fun samplingRate(samplingRate: JsonField) = + apply { + this.samplingRate = samplingRate + } /** The list of scorers to use for online scoring */ fun scorers(scorers: List) = scorers(JsonField.of(scorers)) /** The list of scorers to use for online scoring */ - fun scorers(scorers: JsonField>) = apply { - this.scorers = scorers.map { it.toMutableList() } - } + fun scorers(scorers: JsonField>) = + apply { + this.scorers = scorers.map { it.toMutableList() } + } /** The list of scorers to use for online scoring */ - fun addScorer(scorer: Scorer) = apply { - scorers = - (scorers ?: JsonField.of(mutableListOf())).also { + fun addScorer(scorer: Scorer) = + apply { + scorers = (scorers ?: JsonField.of(mutableListOf())).also { checkKnown("scorers", it).add(scorer) } - } + } /** The list of scorers to use for online scoring */ fun addScorer(function: Scorer.Function) = addScorer(Scorer.ofFunction(function)) @@ -165,78 +162,87 @@ private constructor( fun addScorer(global: Scorer.Global) = addScorer(Scorer.ofGlobal(global)) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: Boolean?) = - applyToRootSpan(JsonField.ofNullable(applyToRootSpan)) + fun applyToRootSpan(applyToRootSpan: Boolean?) = applyToRootSpan(JsonField.ofNullable(applyToRootSpan)) /** Whether to trigger online scoring on the root span of each trace */ fun applyToRootSpan(applyToRootSpan: Boolean) = applyToRootSpan(applyToRootSpan as Boolean?) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: Optional) = - applyToRootSpan(applyToRootSpan.getOrNull()) + fun applyToRootSpan(applyToRootSpan: Optional) = applyToRootSpan(applyToRootSpan.getOrNull()) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: JsonField) = apply { - this.applyToRootSpan = applyToRootSpan - } + fun applyToRootSpan(applyToRootSpan: JsonField) = + apply { + this.applyToRootSpan = applyToRootSpan + } /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: List?) = - applyToSpanNames(JsonField.ofNullable(applyToSpanNames)) + fun applyToSpanNames(applyToSpanNames: List?) = applyToSpanNames(JsonField.ofNullable(applyToSpanNames)) /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: Optional>) = - applyToSpanNames(applyToSpanNames.getOrNull()) + fun applyToSpanNames(applyToSpanNames: Optional>) = applyToSpanNames(applyToSpanNames.getOrNull()) /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: JsonField>) = apply { - this.applyToSpanNames = applyToSpanNames.map { it.toMutableList() } - } + fun applyToSpanNames(applyToSpanNames: JsonField>) = + apply { + this.applyToSpanNames = applyToSpanNames.map { it.toMutableList() } + } /** Trigger online scoring on any spans with a name in this list */ - fun addApplyToSpanName(applyToSpanName: String) = apply { - applyToSpanNames = - (applyToSpanNames ?: JsonField.of(mutableListOf())).also { + fun addApplyToSpanName(applyToSpanName: String) = + apply { + applyToSpanNames = (applyToSpanNames ?: JsonField.of(mutableListOf())).also { checkKnown("applyToSpanNames", it).add(applyToSpanName) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): OnlineScoreConfig = OnlineScoreConfig( - checkRequired("samplingRate", samplingRate), - checkRequired("scorers", scorers).map { it.toImmutable() }, - applyToRootSpan, - (applyToSpanNames ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "samplingRate", samplingRate + ), + checkRequired( + "scorers", scorers + ).map { it.toImmutable() }, + applyToRootSpan, + (applyToSpanNames ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Scorer.Deserializer::class) @JsonSerialize(using = Scorer.Serializer::class) - class Scorer - private constructor( + class Scorer private constructor( private val function: Function? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun function(): Optional = Optional.ofNullable(function) @@ -254,40 +260,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - function != null -> visitor.visitFunction(function) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + function != null -> visitor.visitFunction(function) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Scorer = apply { - if (validated) { - return@apply - } + fun validate(): Scorer = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scorer && function == other.function && global == other.global /* spotless:on */ + return /* spotless:off */ other is Scorer && function == other.function && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(function, global) /* spotless:on */ @@ -302,12 +307,17 @@ private constructor( companion object { - @JvmStatic fun ofFunction(function: Function) = Scorer(function = function) + @JvmStatic + fun ofFunction(function: Function) = Scorer(function = function) - @JvmStatic fun ofGlobal(global: Global) = Scorer(global = global) + @JvmStatic + fun ofGlobal(global: Global) = Scorer(global = global) } - /** An interface that defines how to map each variant of [Scorer] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Scorer] to a value of type + * [T]. + */ interface Visitor { fun visitFunction(function: Function): T @@ -317,73 +327,65 @@ private constructor( /** * Maps an unknown variant of [Scorer] to a value of type [T]. * - * An instance of [Scorer] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Scorer] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Scorer: $json") + throw BraintrustInvalidDataException("Unknown Scorer: $json") } } internal class Deserializer : BaseDeserializer(Scorer::class) { override fun ObjectCodec.deserialize(node: JsonNode): Scorer { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Scorer(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Scorer(global = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Scorer(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Scorer(global = it, _json = json) + } - return Scorer(_json = json) + return Scorer(_json = json) } } internal class Serializer : BaseSerializer(Scorer::class) { - override fun serialize( - value: Scorer, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.function != null -> generator.writeObject(value.function) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Scorer") - } + override fun serialize(value: Scorer, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.function != null -> generator.writeObject(value.function) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Scorer") + } } } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun id(): String = id.getRequired("id") fun type(): Type = type.getRequired("type") - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -391,15 +393,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - id() - type() - validated = true - } + id() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -409,12 +412,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .id() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -425,52 +430,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - id = function.id - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + id = function.id + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("id", id), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -480,7 +502,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -491,23 +514,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { FUNCTION, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -531,7 +554,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -546,19 +569,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -567,11 +587,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -580,31 +600,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -612,15 +629,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -630,12 +648,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -646,52 +666,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -701,7 +738,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -712,23 +750,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -752,7 +790,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -767,19 +805,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -788,11 +823,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -801,17 +836,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OnlineScoreConfig && samplingRate == other.samplingRate && scorers == other.scorers && applyToRootSpan == other.applyToRootSpan && applyToSpanNames == other.applyToSpanNames && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OnlineScoreConfig && samplingRate == other.samplingRate && scorers == other.scorers && applyToRootSpan == other.applyToRootSpan && applyToSpanNames == other.applyToSpanNames && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -820,6 +854,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "OnlineScoreConfig{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" + override fun toString() = "OnlineScoreConfig{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 584931b5..9fc9931a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -20,27 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Organization -@JsonCreator -private constructor( +class Organization @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("api_url") - @ExcludeMissing - private val apiUrl: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("is_universal_api") - @ExcludeMissing - private val isUniversalApi: JsonField = JsonMissing.of(), - @JsonProperty("proxy_url") - @ExcludeMissing - private val proxyUrl: JsonField = JsonMissing.of(), - @JsonProperty("realtime_url") - @ExcludeMissing - private val realtimeUrl: JsonField = JsonMissing.of(), + @JsonProperty("api_url") @ExcludeMissing private val apiUrl: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("is_universal_api") @ExcludeMissing private val isUniversalApi: JsonField = JsonMissing.of(), + @JsonProperty("proxy_url") @ExcludeMissing private val proxyUrl: JsonField = JsonMissing.of(), + @JsonProperty("realtime_url") @ExcludeMissing private val realtimeUrl: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the organization */ @@ -54,30 +43,38 @@ private constructor( /** Date of organization creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - fun isUniversalApi(): Optional = - Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) + fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) - fun realtimeUrl(): Optional = - Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) + fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) /** Unique identifier for the organization */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the organization */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl + @JsonProperty("api_url") + @ExcludeMissing + fun _apiUrl(): JsonField = apiUrl /** Date of organization creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi(): JsonField = isUniversalApi - @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl + @JsonProperty("proxy_url") + @ExcludeMissing + fun _proxyUrl(): JsonField = proxyUrl @JsonProperty("realtime_url") @ExcludeMissing @@ -89,21 +86,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Organization = apply { - if (validated) { - return@apply + fun validate(): Organization = + apply { + if (validated) { + return@apply + } + + id() + name() + apiUrl() + created() + isUniversalApi() + proxyUrl() + realtimeUrl() + validated = true } - id() - name() - apiUrl() - created() - isUniversalApi() - proxyUrl() - realtimeUrl() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -112,12 +110,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Organization]. * * The following fields are required: + * * ```java * .id() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Organization]. */ @@ -133,34 +133,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(organization: Organization) = apply { - id = organization.id - name = organization.name - apiUrl = organization.apiUrl - created = organization.created - isUniversalApi = organization.isUniversalApi - proxyUrl = organization.proxyUrl - realtimeUrl = organization.realtimeUrl - additionalProperties = organization.additionalProperties.toMutableMap() - } + internal fun from(organization: Organization) = + apply { + id = organization.id + name = organization.name + apiUrl = organization.apiUrl + created = organization.created + isUniversalApi = organization.isUniversalApi + proxyUrl = organization.proxyUrl + realtimeUrl = organization.realtimeUrl + additionalProperties = organization.additionalProperties.toMutableMap() + } /** Unique identifier for the organization */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the organization */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the organization */ fun name(name: String) = name(JsonField.of(name)) /** Name of the organization */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) - fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } + fun apiUrl(apiUrl: JsonField) = + apply { + this.apiUrl = apiUrl + } /** Date of organization creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -169,70 +179,89 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of organization creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } - fun isUniversalApi(isUniversalApi: Boolean?) = - isUniversalApi(JsonField.ofNullable(isUniversalApi)) + fun isUniversalApi(isUniversalApi: Boolean?) = isUniversalApi(JsonField.ofNullable(isUniversalApi)) fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - fun isUniversalApi(isUniversalApi: Optional) = - isUniversalApi(isUniversalApi.getOrNull()) + fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) - fun isUniversalApi(isUniversalApi: JsonField) = apply { - this.isUniversalApi = isUniversalApi - } + fun isUniversalApi(isUniversalApi: JsonField) = + apply { + this.isUniversalApi = isUniversalApi + } fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) - fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } + fun proxyUrl(proxyUrl: JsonField) = + apply { + this.proxyUrl = proxyUrl + } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) - fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun realtimeUrl(realtimeUrl: JsonField) = + apply { + this.realtimeUrl = realtimeUrl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Organization = Organization( - checkRequired("id", id), - checkRequired("name", name), - apiUrl, - created, - isUniversalApi, - proxyUrl, - realtimeUrl, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + apiUrl, + created, + isUniversalApi, + proxyUrl, + realtimeUrl, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Organization && id == other.id && name == other.name && apiUrl == other.apiUrl && created == other.created && isUniversalApi == other.isUniversalApi && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Organization && id == other.id && name == other.name && apiUrl == other.apiUrl && created == other.created && isUniversalApi == other.isUniversalApi && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -241,6 +270,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Organization{id=$id, name=$name, apiUrl=$apiUrl, created=$created, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + override fun toString() = "Organization{id=$id, name=$name, apiUrl=$apiUrl, created=$created, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index ba3170a9..cf0c7530 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an organization object by its id */ -class OrganizationDeleteParams -private constructor( +class OrganizationDeleteParams private constructor( private val organizationId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Organization id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [OrganizationDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [OrganizationDeleteParams]. * * The following fields are required: + * * ```java * .organizationId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(organizationDeleteParams: OrganizationDeleteParams) = apply { - organizationId = organizationDeleteParams.organizationId - additionalHeaders = organizationDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - organizationDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(organizationDeleteParams: OrganizationDeleteParams) = + apply { + organizationId = organizationDeleteParams.organizationId + additionalHeaders = organizationDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = organizationDeleteParams.additionalBodyProperties.toMutableMap() + } /** Organization id */ - fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun organizationId(organizationId: String) = + apply { + this.organizationId = organizationId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): OrganizationDeleteParams = OrganizationDeleteParams( - checkRequired("organizationId", organizationId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "organizationId", organizationId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationDeleteParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationDeleteParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index 8bff63be..ecad5972 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.OrganizationService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ -class OrganizationListPage -private constructor( +class OrganizationListPage private constructor( private val organizationsService: OrganizationService, private val params: OrganizationListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationListPage && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is OrganizationListPage && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ - override fun toString() = - "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" + override fun toString() = "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - OrganizationListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - OrganizationListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { organizationsService.list(it) } + return getNextPageParams().map { organizationsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - organizationsService: OrganizationService, - params: OrganizationListParams, - response: Response, - ) = OrganizationListPage(organizationsService, params, response) + fun of(organizationsService: OrganizationService, params: OrganizationListParams, response: Response) = + OrganizationListPage( + organizationsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** Returns a mutable builder for constructing an instance of [OrganizationListPage]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [OrganizationListPage]. + */ + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +139,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: OrganizationListPage) : Iterable { + class AutoPager( + private val firstPage: OrganizationListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index cdc6536a..66136ad2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.OrganizationServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ -class OrganizationListPageAsync -private constructor( +class OrganizationListPageAsync private constructor( private val organizationsService: OrganizationServiceAsync, private val params: OrganizationListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationListPageAsync && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is OrganizationListPageAsync && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ - override fun toString() = - "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" + override fun toString() = "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - OrganizationListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - OrganizationListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { organizationsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + organizationsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - organizationsService: OrganizationServiceAsync, - params: OrganizationListParams, - response: Response, - ) = OrganizationListPageAsync(organizationsService, params, response) + fun of(organizationsService: OrganizationServiceAsync, params: OrganizationListParams, response: Response) = + OrganizationListPageAsync( + organizationsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,29 +106,29 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -143,7 +136,8 @@ private constructor( * Returns a mutable builder for constructing an instance of * [OrganizationListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -152,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: OrganizationListPageAsync) { + class AutoPager( + private val firstPage: OrganizationListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Organization) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Organization) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index d01ebbf0..030263de 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ -class OrganizationListParams -private constructor( +class OrganizationListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -35,20 +34,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -61,9 +61,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -74,24 +74,49 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): OrganizationListParams = builder().build() + @JvmStatic + fun none(): OrganizationListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [OrganizationListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [OrganizationListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationListParams]. */ @@ -107,60 +132,70 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationListParams: OrganizationListParams) = apply { - endingBefore = organizationListParams.endingBefore - ids = organizationListParams.ids - limit = organizationListParams.limit - orgName = organizationListParams.orgName - startingAfter = organizationListParams.startingAfter - additionalHeaders = organizationListParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationListParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationListParams: OrganizationListParams) = + apply { + endingBefore = organizationListParams.endingBefore + ids = organizationListParams.ids + limit = organizationListParams.limit + orgName = organizationListParams.orgName + startingAfter = organizationListParams.startingAfter + additionalHeaders = organizationListParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -169,7 +204,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -177,143 +215,171 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationListParams = OrganizationListParams( - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -331,19 +397,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -358,12 +424,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -373,60 +444,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index f75b1abe..8c4a6abb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -22,27 +22,29 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Modify organization membership */ -class OrganizationMemberUpdateParams -private constructor( +class OrganizationMemberUpdateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Users to invite to the organization */ fun inviteUsers(): Optional = body.inviteUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(): Optional = body.orgId() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(): Optional = body.orgName() @@ -53,16 +55,18 @@ private constructor( fun _inviteUsers(): JsonField = body._inviteUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun _orgId(): JsonField = body._orgId() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun _orgName(): JsonField = body._orgName() @@ -75,53 +79,44 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("invite_users") - @ExcludeMissing - private val inviteUsers: JsonField = JsonMissing.of(), - @JsonProperty("org_id") - @ExcludeMissing - private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonProperty("remove_users") - @ExcludeMissing - private val removeUsers: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("invite_users") @ExcludeMissing private val inviteUsers: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("remove_users") @ExcludeMissing private val removeUsers: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Users to invite to the organization */ - fun inviteUsers(): Optional = - Optional.ofNullable(inviteUsers.getNullable("invite_users")) + fun inviteUsers(): Optional = Optional.ofNullable(inviteUsers.getNullable("invite_users")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Users to remove from the organization */ - fun removeUsers(): Optional = - Optional.ofNullable(removeUsers.getNullable("remove_users")) + fun removeUsers(): Optional = Optional.ofNullable(removeUsers.getNullable("remove_users")) /** Users to invite to the organization */ @JsonProperty("invite_users") @@ -129,18 +124,24 @@ private constructor( fun _inviteUsers(): JsonField = inviteUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName /** Users to remove from the organization */ @JsonProperty("remove_users") @@ -153,24 +154,26 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + inviteUsers().ifPresent { it.validate() } + orgId() + orgName() + removeUsers().ifPresent { it.validate() } + validated = true } - inviteUsers().ifPresent { it.validate() } - orgId() - orgName() - removeUsers().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -183,117 +186,135 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - inviteUsers = body.inviteUsers - orgId = body.orgId - orgName = body.orgName - removeUsers = body.removeUsers - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + inviteUsers = body.inviteUsers + orgId = body.orgId + orgName = body.orgName + removeUsers = body.removeUsers + additionalProperties = body.additionalProperties.toMutableMap() + } /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: InviteUsers?) = - inviteUsers(JsonField.ofNullable(inviteUsers)) + fun inviteUsers(inviteUsers: InviteUsers?) = inviteUsers(JsonField.ofNullable(inviteUsers)) /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: Optional) = - inviteUsers(inviteUsers.getOrNull()) + fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.getOrNull()) /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: JsonField) = apply { - this.inviteUsers = inviteUsers - } + fun inviteUsers(inviteUsers: JsonField) = + apply { + this.inviteUsers = inviteUsers + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the id of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the id of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the id of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the name of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the name of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the name of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } /** Users to remove from the organization */ - fun removeUsers(removeUsers: RemoveUsers?) = - removeUsers(JsonField.ofNullable(removeUsers)) + fun removeUsers(removeUsers: RemoveUsers?) = removeUsers(JsonField.ofNullable(removeUsers)) /** Users to remove from the organization */ - fun removeUsers(removeUsers: Optional) = - removeUsers(removeUsers.getOrNull()) + fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.getOrNull()) /** Users to remove from the organization */ - fun removeUsers(removeUsers: JsonField) = apply { - this.removeUsers = removeUsers - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeUsers(removeUsers: JsonField) = + apply { + this.removeUsers = removeUsers + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(inviteUsers, orgId, orgName, removeUsers, additionalProperties.toImmutable()) + Body( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -302,21 +323,22 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" + override fun toString() = "Body{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): OrganizationMemberUpdateParams = builder().build() + @JvmStatic + fun none(): OrganizationMemberUpdateParams = builder().build() /** * Returns a mutable builder for constructing an instance of * [OrganizationMemberUpdateParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationMemberUpdateParams]. */ @@ -328,229 +350,274 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationMemberUpdateParams: OrganizationMemberUpdateParams) = apply { - body = organizationMemberUpdateParams.body.toBuilder() - additionalHeaders = organizationMemberUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationMemberUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationMemberUpdateParams: OrganizationMemberUpdateParams) = + apply { + body = organizationMemberUpdateParams.body.toBuilder() + additionalHeaders = organizationMemberUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationMemberUpdateParams.additionalQueryParams.toBuilder() + } /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: InviteUsers?) = apply { body.inviteUsers(inviteUsers) } + fun inviteUsers(inviteUsers: InviteUsers?) = + apply { + body.inviteUsers(inviteUsers) + } /** Users to invite to the organization */ fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.getOrNull()) /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: JsonField) = apply { - body.inviteUsers(inviteUsers) - } + fun inviteUsers(inviteUsers: JsonField) = + apply { + body.inviteUsers(inviteUsers) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ - fun orgId(orgId: String?) = apply { body.orgId(orgId) } + fun orgId(orgId: String?) = + apply { + body.orgId(orgId) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ - fun orgId(orgId: JsonField) = apply { body.orgId(orgId) } + fun orgId(orgId: JsonField) = + apply { + body.orgId(orgId) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } /** Users to remove from the organization */ - fun removeUsers(removeUsers: RemoveUsers?) = apply { body.removeUsers(removeUsers) } + fun removeUsers(removeUsers: RemoveUsers?) = + apply { + body.removeUsers(removeUsers) + } /** Users to remove from the organization */ fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.getOrNull()) /** Users to remove from the organization */ - fun removeUsers(removeUsers: JsonField) = apply { - body.removeUsers(removeUsers) - } + fun removeUsers(removeUsers: JsonField) = + apply { + body.removeUsers(removeUsers) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationMemberUpdateParams = OrganizationMemberUpdateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** Users to invite to the organization */ @NoAutoDetect - class InviteUsers - @JsonCreator - private constructor( - @JsonProperty("emails") - @ExcludeMissing - private val emails: JsonField> = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("group_ids") - @ExcludeMissing - private val groupIds: JsonField> = JsonMissing.of(), - @JsonProperty("group_name") - @ExcludeMissing - private val groupName: JsonField = JsonMissing.of(), - @JsonProperty("group_names") - @ExcludeMissing - private val groupNames: JsonField> = JsonMissing.of(), - @JsonProperty("ids") - @ExcludeMissing - private val ids: JsonField> = JsonMissing.of(), - @JsonProperty("send_invite_emails") - @ExcludeMissing - private val sendInviteEmails: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InviteUsers @JsonCreator private constructor( + @JsonProperty("emails") @ExcludeMissing private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("group_ids") @ExcludeMissing private val groupIds: JsonField> = JsonMissing.of(), + @JsonProperty("group_name") @ExcludeMissing private val groupName: JsonField = JsonMissing.of(), + @JsonProperty("group_names") @ExcludeMissing private val groupNames: JsonField> = JsonMissing.of(), + @JsonProperty("ids") @ExcludeMissing private val ids: JsonField> = JsonMissing.of(), + @JsonProperty("send_invite_emails") @ExcludeMissing private val sendInviteEmails: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Emails of users to invite */ @@ -560,28 +627,29 @@ private constructor( fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) /** Optional list of group ids to add newly-invited users to. */ - fun groupIds(): Optional> = - Optional.ofNullable(groupIds.getNullable("group_ids")) + fun groupIds(): Optional> = Optional.ofNullable(groupIds.getNullable("group_ids")) /** Singular form of group_names */ fun groupName(): Optional = Optional.ofNullable(groupName.getNullable("group_name")) /** Optional list of group names to add newly-invited users to. */ - fun groupNames(): Optional> = - Optional.ofNullable(groupNames.getNullable("group_names")) + fun groupNames(): Optional> = Optional.ofNullable(groupNames.getNullable("group_names")) /** Ids of existing users to invite */ fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(): Optional = - Optional.ofNullable(sendInviteEmails.getNullable("send_invite_emails")) + fun sendInviteEmails(): Optional = Optional.ofNullable(sendInviteEmails.getNullable("send_invite_emails")) /** Emails of users to invite */ - @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails + @JsonProperty("emails") + @ExcludeMissing + fun _emails(): JsonField> = emails /** Singular form of group_ids */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId /** Optional list of group ids to add newly-invited users to. */ @JsonProperty("group_ids") @@ -589,7 +657,9 @@ private constructor( fun _groupIds(): JsonField> = groupIds /** Singular form of group_names */ - @JsonProperty("group_name") @ExcludeMissing fun _groupName(): JsonField = groupName + @JsonProperty("group_name") + @ExcludeMissing + fun _groupName(): JsonField = groupName /** Optional list of group names to add newly-invited users to. */ @JsonProperty("group_names") @@ -597,7 +667,9 @@ private constructor( fun _groupNames(): JsonField> = groupNames /** Ids of existing users to invite */ - @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids + @JsonProperty("ids") + @ExcludeMissing + fun _ids(): JsonField> = ids /** If true, send invite emails to the users who wore actually added */ @JsonProperty("send_invite_emails") @@ -610,27 +682,29 @@ private constructor( private var validated: Boolean = false - fun validate(): InviteUsers = apply { - if (validated) { - return@apply + fun validate(): InviteUsers = + apply { + if (validated) { + return@apply + } + + emails() + groupId() + groupIds() + groupName() + groupNames() + ids() + sendInviteEmails() + validated = true } - emails() - groupId() - groupIds() - groupName() - groupNames() - ids() - sendInviteEmails() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [InviteUsers]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InviteUsers]. */ @@ -646,16 +720,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inviteUsers: InviteUsers) = apply { - emails = inviteUsers.emails.map { it.toMutableList() } - groupId = inviteUsers.groupId - groupIds = inviteUsers.groupIds.map { it.toMutableList() } - groupName = inviteUsers.groupName - groupNames = inviteUsers.groupNames.map { it.toMutableList() } - ids = inviteUsers.ids.map { it.toMutableList() } - sendInviteEmails = inviteUsers.sendInviteEmails - additionalProperties = inviteUsers.additionalProperties.toMutableMap() - } + internal fun from(inviteUsers: InviteUsers) = + apply { + emails = inviteUsers.emails.map { it.toMutableList() } + groupId = inviteUsers.groupId + groupIds = inviteUsers.groupIds.map { it.toMutableList() } + groupName = inviteUsers.groupName + groupNames = inviteUsers.groupNames.map { it.toMutableList() } + ids = inviteUsers.ids.map { it.toMutableList() } + sendInviteEmails = inviteUsers.sendInviteEmails + additionalProperties = inviteUsers.additionalProperties.toMutableMap() + } /** Emails of users to invite */ fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) @@ -664,17 +739,18 @@ private constructor( fun emails(emails: Optional>) = emails(emails.getOrNull()) /** Emails of users to invite */ - fun emails(emails: JsonField>) = apply { - this.emails = emails.map { it.toMutableList() } - } + fun emails(emails: JsonField>) = + apply { + this.emails = emails.map { it.toMutableList() } + } /** Emails of users to invite */ - fun addEmail(email: String) = apply { - emails = - (emails ?: JsonField.of(mutableListOf())).also { + fun addEmail(email: String) = + apply { + emails = (emails ?: JsonField.of(mutableListOf())).also { checkKnown("emails", it).add(email) } - } + } /** Singular form of group_ids */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) @@ -683,7 +759,10 @@ private constructor( fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** Singular form of group_ids */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** Optional list of group ids to add newly-invited users to. */ fun groupIds(groupIds: List?) = groupIds(JsonField.ofNullable(groupIds)) @@ -692,17 +771,18 @@ private constructor( fun groupIds(groupIds: Optional>) = groupIds(groupIds.getOrNull()) /** Optional list of group ids to add newly-invited users to. */ - fun groupIds(groupIds: JsonField>) = apply { - this.groupIds = groupIds.map { it.toMutableList() } - } + fun groupIds(groupIds: JsonField>) = + apply { + this.groupIds = groupIds.map { it.toMutableList() } + } /** Optional list of group ids to add newly-invited users to. */ - fun addGroupId(groupId: String) = apply { - groupIds = - (groupIds ?: JsonField.of(mutableListOf())).also { + fun addGroupId(groupId: String) = + apply { + groupIds = (groupIds ?: JsonField.of(mutableListOf())).also { checkKnown("groupIds", it).add(groupId) } - } + } /** Singular form of group_names */ fun groupName(groupName: String?) = groupName(JsonField.ofNullable(groupName)) @@ -711,7 +791,10 @@ private constructor( fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) /** Singular form of group_names */ - fun groupName(groupName: JsonField) = apply { this.groupName = groupName } + fun groupName(groupName: JsonField) = + apply { + this.groupName = groupName + } /** Optional list of group names to add newly-invited users to. */ fun groupNames(groupNames: List?) = groupNames(JsonField.ofNullable(groupNames)) @@ -720,17 +803,18 @@ private constructor( fun groupNames(groupNames: Optional>) = groupNames(groupNames.getOrNull()) /** Optional list of group names to add newly-invited users to. */ - fun groupNames(groupNames: JsonField>) = apply { - this.groupNames = groupNames.map { it.toMutableList() } - } + fun groupNames(groupNames: JsonField>) = + apply { + this.groupNames = groupNames.map { it.toMutableList() } + } /** Optional list of group names to add newly-invited users to. */ - fun addGroupName(groupName: String) = apply { - groupNames = - (groupNames ?: JsonField.of(mutableListOf())).also { + fun addGroupName(groupName: String) = + apply { + groupNames = (groupNames ?: JsonField.of(mutableListOf())).also { checkKnown("groupNames", it).add(groupName) } - } + } /** Ids of existing users to invite */ fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) @@ -739,70 +823,79 @@ private constructor( fun ids(ids: Optional>) = ids(ids.getOrNull()) /** Ids of existing users to invite */ - fun ids(ids: JsonField>) = apply { - this.ids = ids.map { it.toMutableList() } - } + fun ids(ids: JsonField>) = + apply { + this.ids = ids.map { it.toMutableList() } + } /** Ids of existing users to invite */ - fun addId(id: String) = apply { - ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } - } + fun addId(id: String) = + apply { + ids = (ids ?: JsonField.of(mutableListOf())).also { + checkKnown("ids", it).add(id) + } + } /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Boolean?) = - sendInviteEmails(JsonField.ofNullable(sendInviteEmails)) + fun sendInviteEmails(sendInviteEmails: Boolean?) = sendInviteEmails(JsonField.ofNullable(sendInviteEmails)) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Boolean) = - sendInviteEmails(sendInviteEmails as Boolean?) + fun sendInviteEmails(sendInviteEmails: Boolean) = sendInviteEmails(sendInviteEmails as Boolean?) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Optional) = - sendInviteEmails(sendInviteEmails.getOrNull()) + fun sendInviteEmails(sendInviteEmails: Optional) = sendInviteEmails(sendInviteEmails.getOrNull()) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: JsonField) = apply { - this.sendInviteEmails = sendInviteEmails - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun sendInviteEmails(sendInviteEmails: JsonField) = + apply { + this.sendInviteEmails = sendInviteEmails + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InviteUsers = InviteUsers( - (emails ?: JsonMissing.of()).map { it.toImmutable() }, - groupId, - (groupIds ?: JsonMissing.of()).map { it.toImmutable() }, - groupName, - (groupNames ?: JsonMissing.of()).map { it.toImmutable() }, - (ids ?: JsonMissing.of()).map { it.toImmutable() }, - sendInviteEmails, - additionalProperties.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, + groupId, + (groupIds ?: JsonMissing.of()).map { it.toImmutable() }, + groupName, + (groupNames ?: JsonMissing.of()).map { it.toImmutable() }, + (ids ?: JsonMissing.of()).map { it.toImmutable() }, + sendInviteEmails, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InviteUsers && emails == other.emails && groupId == other.groupId && groupIds == other.groupIds && groupName == other.groupName && groupNames == other.groupNames && ids == other.ids && sendInviteEmails == other.sendInviteEmails && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InviteUsers && emails == other.emails && groupId == other.groupId && groupIds == other.groupIds && groupName == other.groupName && groupNames == other.groupNames && ids == other.ids && sendInviteEmails == other.sendInviteEmails && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -811,23 +904,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InviteUsers{emails=$emails, groupId=$groupId, groupIds=$groupIds, groupName=$groupName, groupNames=$groupNames, ids=$ids, sendInviteEmails=$sendInviteEmails, additionalProperties=$additionalProperties}" + override fun toString() = "InviteUsers{emails=$emails, groupId=$groupId, groupIds=$groupIds, groupName=$groupName, groupNames=$groupNames, ids=$ids, sendInviteEmails=$sendInviteEmails, additionalProperties=$additionalProperties}" } /** Users to remove from the organization */ @NoAutoDetect - class RemoveUsers - @JsonCreator - private constructor( - @JsonProperty("emails") - @ExcludeMissing - private val emails: JsonField> = JsonMissing.of(), - @JsonProperty("ids") - @ExcludeMissing - private val ids: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RemoveUsers @JsonCreator private constructor( + @JsonProperty("emails") @ExcludeMissing private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("ids") @ExcludeMissing private val ids: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Emails of users to remove */ @@ -837,10 +923,14 @@ private constructor( fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) /** Emails of users to remove */ - @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails + @JsonProperty("emails") + @ExcludeMissing + fun _emails(): JsonField> = emails /** Ids of users to remove */ - @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids + @JsonProperty("ids") + @ExcludeMissing + fun _ids(): JsonField> = ids @JsonAnyGetter @ExcludeMissing @@ -848,22 +938,24 @@ private constructor( private var validated: Boolean = false - fun validate(): RemoveUsers = apply { - if (validated) { - return@apply - } + fun validate(): RemoveUsers = + apply { + if (validated) { + return@apply + } - emails() - ids() - validated = true - } + emails() + ids() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [RemoveUsers]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RemoveUsers]. */ @@ -874,11 +966,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeUsers: RemoveUsers) = apply { - emails = removeUsers.emails.map { it.toMutableList() } - ids = removeUsers.ids.map { it.toMutableList() } - additionalProperties = removeUsers.additionalProperties.toMutableMap() - } + internal fun from(removeUsers: RemoveUsers) = + apply { + emails = removeUsers.emails.map { it.toMutableList() } + ids = removeUsers.ids.map { it.toMutableList() } + additionalProperties = removeUsers.additionalProperties.toMutableMap() + } /** Emails of users to remove */ fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) @@ -887,17 +980,18 @@ private constructor( fun emails(emails: Optional>) = emails(emails.getOrNull()) /** Emails of users to remove */ - fun emails(emails: JsonField>) = apply { - this.emails = emails.map { it.toMutableList() } - } + fun emails(emails: JsonField>) = + apply { + this.emails = emails.map { it.toMutableList() } + } /** Emails of users to remove */ - fun addEmail(email: String) = apply { - emails = - (emails ?: JsonField.of(mutableListOf())).also { + fun addEmail(email: String) = + apply { + emails = (emails ?: JsonField.of(mutableListOf())).also { checkKnown("emails", it).add(email) } - } + } /** Ids of users to remove */ fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) @@ -906,48 +1000,59 @@ private constructor( fun ids(ids: Optional>) = ids(ids.getOrNull()) /** Ids of users to remove */ - fun ids(ids: JsonField>) = apply { - this.ids = ids.map { it.toMutableList() } - } + fun ids(ids: JsonField>) = + apply { + this.ids = ids.map { it.toMutableList() } + } /** Ids of users to remove */ - fun addId(id: String) = apply { - ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addId(id: String) = + apply { + ids = (ids ?: JsonField.of(mutableListOf())).also { + checkKnown("ids", it).add(id) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RemoveUsers = RemoveUsers( - (emails ?: JsonMissing.of()).map { it.toImmutable() }, - (ids ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, + (ids ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RemoveUsers && emails == other.emails && ids == other.ids && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveUsers && emails == other.emails && ids == other.ids && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -956,20 +1061,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RemoveUsers{emails=$emails, ids=$ids, additionalProperties=$additionalProperties}" + override fun toString() = "RemoveUsers{emails=$emails, ids=$ids, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationMemberUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationMemberUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "OrganizationMemberUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "OrganizationMemberUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 3d45ef35..75ac31bf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an organization object by its id */ -class OrganizationRetrieveParams -private constructor( +class OrganizationRetrieveParams private constructor( private val organizationId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Organization id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [OrganizationRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [OrganizationRetrieveParams]. * * The following fields are required: + * * ```java * .organizationId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = apply { - organizationId = organizationRetrieveParams.organizationId - additionalHeaders = organizationRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = + apply { + organizationId = organizationRetrieveParams.organizationId + additionalHeaders = organizationRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationRetrieveParams.additionalQueryParams.toBuilder() + } /** Organization id */ - fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun organizationId(organizationId: String) = + apply { + this.organizationId = organizationId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( - checkRequired("organizationId", organizationId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "organizationId", organizationId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationRetrieveParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationRetrieveParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 83efeac1..07a403a7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an organization object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an organization object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class OrganizationUpdateParams -private constructor( +class OrganizationUpdateParams private constructor( private val organizationId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Organization id */ @@ -65,65 +65,58 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("api_url") - @ExcludeMissing - private val apiUrl: JsonField = JsonMissing.of(), - @JsonProperty("is_universal_api") - @ExcludeMissing - private val isUniversalApi: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("proxy_url") - @ExcludeMissing - private val proxyUrl: JsonField = JsonMissing.of(), - @JsonProperty("realtime_url") - @ExcludeMissing - private val realtimeUrl: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("api_url") @ExcludeMissing private val apiUrl: JsonField = JsonMissing.of(), + @JsonProperty("is_universal_api") @ExcludeMissing private val isUniversalApi: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("proxy_url") @ExcludeMissing private val proxyUrl: JsonField = JsonMissing.of(), + @JsonProperty("realtime_url") @ExcludeMissing private val realtimeUrl: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun apiUrl(): Optional = Optional.ofNullable(apiUrl.getNullable("api_url")) - fun isUniversalApi(): Optional = - Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) + fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) /** Name of the organization */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) - fun realtimeUrl(): Optional = - Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) + fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) - @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl + @JsonProperty("api_url") + @ExcludeMissing + fun _apiUrl(): JsonField = apiUrl @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi(): JsonField = isUniversalApi /** Name of the organization */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl + @JsonProperty("proxy_url") + @ExcludeMissing + fun _proxyUrl(): JsonField = proxyUrl @JsonProperty("realtime_url") @ExcludeMissing @@ -135,25 +128,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + apiUrl() + isUniversalApi() + name() + proxyUrl() + realtimeUrl() + validated = true } - apiUrl() - isUniversalApi() - name() - proxyUrl() - realtimeUrl() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -167,32 +162,35 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - apiUrl = body.apiUrl - isUniversalApi = body.isUniversalApi - name = body.name - proxyUrl = body.proxyUrl - realtimeUrl = body.realtimeUrl - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + apiUrl = body.apiUrl + isUniversalApi = body.isUniversalApi + name = body.name + proxyUrl = body.proxyUrl + realtimeUrl = body.realtimeUrl + additionalProperties = body.additionalProperties.toMutableMap() + } fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) - fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } + fun apiUrl(apiUrl: JsonField) = + apply { + this.apiUrl = apiUrl + } - fun isUniversalApi(isUniversalApi: Boolean?) = - isUniversalApi(JsonField.ofNullable(isUniversalApi)) + fun isUniversalApi(isUniversalApi: Boolean?) = isUniversalApi(JsonField.ofNullable(isUniversalApi)) fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - fun isUniversalApi(isUniversalApi: Optional) = - isUniversalApi(isUniversalApi.getOrNull()) + fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) - fun isUniversalApi(isUniversalApi: JsonField) = apply { - this.isUniversalApi = isUniversalApi - } + fun isUniversalApi(isUniversalApi: JsonField) = + apply { + this.isUniversalApi = isUniversalApi + } /** Name of the organization */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -201,58 +199,72 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the organization */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) - fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } + fun proxyUrl(proxyUrl: JsonField) = + apply { + this.proxyUrl = proxyUrl + } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) - fun realtimeUrl(realtimeUrl: JsonField) = apply { - this.realtimeUrl = realtimeUrl - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun realtimeUrl(realtimeUrl: JsonField) = + apply { + this.realtimeUrl = realtimeUrl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalProperties.toImmutable(), + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -261,8 +273,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + override fun toString() = "Body{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -270,14 +281,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [OrganizationUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [OrganizationUpdateParams]. * * The following fields are required: + * * ```java * .organizationId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationUpdateParams]. */ @@ -290,190 +304,256 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationUpdateParams: OrganizationUpdateParams) = apply { - organizationId = organizationUpdateParams.organizationId - body = organizationUpdateParams.body.toBuilder() - additionalHeaders = organizationUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationUpdateParams: OrganizationUpdateParams) = + apply { + organizationId = organizationUpdateParams.organizationId + body = organizationUpdateParams.body.toBuilder() + additionalHeaders = organizationUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() + } /** Organization id */ - fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun organizationId(organizationId: String) = + apply { + this.organizationId = organizationId + } - fun apiUrl(apiUrl: String?) = apply { body.apiUrl(apiUrl) } + fun apiUrl(apiUrl: String?) = + apply { + body.apiUrl(apiUrl) + } fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) - fun apiUrl(apiUrl: JsonField) = apply { body.apiUrl(apiUrl) } + fun apiUrl(apiUrl: JsonField) = + apply { + body.apiUrl(apiUrl) + } - fun isUniversalApi(isUniversalApi: Boolean?) = apply { body.isUniversalApi(isUniversalApi) } + fun isUniversalApi(isUniversalApi: Boolean?) = + apply { + body.isUniversalApi(isUniversalApi) + } fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - fun isUniversalApi(isUniversalApi: Optional) = - isUniversalApi(isUniversalApi.getOrNull()) + fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) - fun isUniversalApi(isUniversalApi: JsonField) = apply { - body.isUniversalApi(isUniversalApi) - } + fun isUniversalApi(isUniversalApi: JsonField) = + apply { + body.isUniversalApi(isUniversalApi) + } /** Name of the organization */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the organization */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the organization */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun proxyUrl(proxyUrl: String?) = apply { body.proxyUrl(proxyUrl) } + fun proxyUrl(proxyUrl: String?) = + apply { + body.proxyUrl(proxyUrl) + } fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) - fun proxyUrl(proxyUrl: JsonField) = apply { body.proxyUrl(proxyUrl) } + fun proxyUrl(proxyUrl: JsonField) = + apply { + body.proxyUrl(proxyUrl) + } - fun realtimeUrl(realtimeUrl: String?) = apply { body.realtimeUrl(realtimeUrl) } + fun realtimeUrl(realtimeUrl: String?) = + apply { + body.realtimeUrl(realtimeUrl) + } fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) - fun realtimeUrl(realtimeUrl: JsonField) = apply { body.realtimeUrl(realtimeUrl) } + fun realtimeUrl(realtimeUrl: JsonField) = + apply { + body.realtimeUrl(realtimeUrl) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationUpdateParams = OrganizationUpdateParams( - checkRequired("organizationId", organizationId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "organizationId", organizationId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "OrganizationUpdateParams{organizationId=$organizationId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "OrganizationUpdateParams{organizationId=$organizationId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index c1bb28cb..932a8cd1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -21,17 +21,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class PatchOrganizationMembersOutput -@JsonCreator -private constructor( +class PatchOrganizationMembersOutput @JsonCreator private constructor( @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("send_email_error") - @ExcludeMissing - private val sendEmailError: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), + @JsonProperty("send_email_error") @ExcludeMissing private val sendEmailError: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the org that was modified. */ @@ -40,20 +35,23 @@ private constructor( fun status(): Status = status.getRequired("status") /** - * If invite emails failed to send for some reason, the patch operation will still complete, but - * we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ - fun sendEmailError(): Optional = - Optional.ofNullable(sendEmailError.getNullable("send_email_error")) + fun sendEmailError(): Optional = Optional.ofNullable(sendEmailError.getNullable("send_email_error")) /** The id of the org that was modified. */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status /** - * If invite emails failed to send for some reason, the patch operation will still complete, but - * we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ @JsonProperty("send_email_error") @ExcludeMissing @@ -65,16 +63,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PatchOrganizationMembersOutput = apply { - if (validated) { - return@apply - } + fun validate(): PatchOrganizationMembersOutput = + apply { + if (validated) { + return@apply + } - orgId() - status() - sendEmailError() - validated = true - } + orgId() + status() + sendEmailError() + validated = true + } fun toBuilder() = Builder().from(this) @@ -85,12 +84,14 @@ private constructor( * [PatchOrganizationMembersOutput]. * * The following fields are required: + * * ```java * .orgId() * .status() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PatchOrganizationMembersOutput]. */ @@ -102,85 +103,105 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = apply { - orgId = patchOrganizationMembersOutput.orgId - status = patchOrganizationMembersOutput.status - sendEmailError = patchOrganizationMembersOutput.sendEmailError - additionalProperties = - patchOrganizationMembersOutput.additionalProperties.toMutableMap() - } + internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = + apply { + orgId = patchOrganizationMembersOutput.orgId + status = patchOrganizationMembersOutput.status + sendEmailError = patchOrganizationMembersOutput.sendEmailError + additionalProperties = patchOrganizationMembersOutput.additionalProperties.toMutableMap() + } /** The id of the org that was modified. */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** The id of the org that was modified. */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } fun status(status: Status) = status(JsonField.of(status)) - fun status(status: JsonField) = apply { this.status = status } + fun status(status: JsonField) = + apply { + this.status = status + } /** - * If invite emails failed to send for some reason, the patch operation will still complete, - * but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ - fun sendEmailError(sendEmailError: String?) = - sendEmailError(JsonField.ofNullable(sendEmailError)) + fun sendEmailError(sendEmailError: String?) = sendEmailError(JsonField.ofNullable(sendEmailError)) /** - * If invite emails failed to send for some reason, the patch operation will still complete, - * but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ - fun sendEmailError(sendEmailError: Optional) = - sendEmailError(sendEmailError.getOrNull()) + fun sendEmailError(sendEmailError: Optional) = sendEmailError(sendEmailError.getOrNull()) /** - * If invite emails failed to send for some reason, the patch operation will still complete, - * but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ - fun sendEmailError(sendEmailError: JsonField) = apply { - this.sendEmailError = sendEmailError - } + fun sendEmailError(sendEmailError: JsonField) = + apply { + this.sendEmailError = sendEmailError + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PatchOrganizationMembersOutput = PatchOrganizationMembersOutput( - checkRequired("orgId", orgId), - checkRequired("status", status), - sendEmailError, - additionalProperties.toImmutable(), + checkRequired( + "orgId", orgId + ), + checkRequired( + "status", status + ), + sendEmailError, + additionalProperties.toImmutable(), ) } - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + class Status @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -191,16 +212,18 @@ private constructor( /** An enum containing [Status]'s known values. */ enum class Known { - SUCCESS + SUCCESS, } /** * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -210,11 +233,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -225,11 +248,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -240,23 +263,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -265,11 +285,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PatchOrganizationMembersOutput && orgId == other.orgId && status == other.status && sendEmailError == other.sendEmailError && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PatchOrganizationMembersOutput && orgId == other.orgId && status == other.status && sendEmailError == other.sendEmailError && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -278,6 +298,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PatchOrganizationMembersOutput{orgId=$orgId, status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" + override fun toString() = "PatchOrganizationMembersOutput{orgId=$orgId, status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index 8da4413e..698f529c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -20,25 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Project -@JsonCreator -private constructor( +class Project @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("settings") - @ExcludeMissing - private val settings: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("settings") @ExcludeMissing private val settings: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the project */ @@ -54,36 +45,46 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of project deletion, or null if the project is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - fun settings(): Optional = - Optional.ofNullable(settings.getNullable("settings")) + fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) /** Identifies the user who created the project */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the project */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Date of project creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of project deletion, or null if the project is still active */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonField = settings + @JsonProperty("settings") + @ExcludeMissing + fun _settings(): JsonField = settings /** Identifies the user who created the project */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -91,21 +92,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Project = apply { - if (validated) { - return@apply + fun validate(): Project = + apply { + if (validated) { + return@apply + } + + id() + name() + orgId() + created() + deletedAt() + settings().ifPresent { it.validate() } + userId() + validated = true } - id() - name() - orgId() - created() - deletedAt() - settings().ifPresent { it.validate() } - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -114,13 +116,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Project]. * * The following fields are required: + * * ```java * .id() * .name() * .orgId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Project]. */ @@ -136,34 +140,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(project: Project) = apply { - id = project.id - name = project.name - orgId = project.orgId - created = project.created - deletedAt = project.deletedAt - settings = project.settings - userId = project.userId - additionalProperties = project.additionalProperties.toMutableMap() - } + internal fun from(project: Project) = + apply { + id = project.id + name = project.name + orgId = project.orgId + created = project.created + deletedAt = project.deletedAt + settings = project.settings + userId = project.userId + additionalProperties = project.additionalProperties.toMutableMap() + } /** Unique identifier for the project */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique id for the organization that the project belongs under */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Date of project creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -172,7 +186,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of project creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of project deletion, or null if the project is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -181,13 +198,19 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of project deletion, or null if the project is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) fun settings(settings: Optional) = settings(settings.getOrNull()) - fun settings(settings: JsonField) = apply { this.settings = settings } + fun settings(settings: JsonField) = + apply { + this.settings = settings + } /** Identifies the user who created the project */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -196,46 +219,62 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the project */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Project = Project( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("orgId", orgId), - created, - deletedAt, - settings, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + created, + deletedAt, + settings, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Project && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && settings == other.settings && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Project && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && settings == other.settings && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -244,6 +283,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Project{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, settings=$settings, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Project{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, settings=$settings, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 6d92a603..3b391d17 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -22,23 +22,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new project. If there is an existing project with the same name as the one specified in - * the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the + * one specified in the request, will return the existing project unmodified */ -class ProjectCreateParams -private constructor( +class ProjectCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project */ fun name(): String = body.name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(): Optional = body.orgName() @@ -46,9 +46,9 @@ private constructor( fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -58,45 +58,44 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project */ fun name(): String = name.getRequired("name") /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -104,15 +103,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - orgName() - validated = true - } + name() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -122,11 +122,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -137,68 +139,88 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) + Body( + checkRequired( + "name", name + ), + orgName, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -207,8 +229,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -219,11 +240,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectCreateParams]. */ @@ -235,174 +258,220 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectCreateParams: ProjectCreateParams) = apply { - body = projectCreateParams.body.toBuilder() - additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectCreateParams: ProjectCreateParams) = + apply { + body = projectCreateParams.body.toBuilder() + additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() + } /** Name of the project */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectCreateParams = ProjectCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 969df0a9..68da5858 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a project object by its id */ -class ProjectDeleteParams -private constructor( +class ProjectDeleteParams private constructor( private val projectId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Project id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectDeleteParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectDeleteParams: ProjectDeleteParams) = apply { - projectId = projectDeleteParams.projectId - additionalHeaders = projectDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = projectDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = projectDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(projectDeleteParams: ProjectDeleteParams) = + apply { + projectId = projectDeleteParams.projectId + additionalHeaders = projectDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectDeleteParams.additionalBodyProperties.toMutableMap() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ProjectDeleteParams = ProjectDeleteParams( - checkRequired("projectId", projectId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "projectId", projectId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectDeleteParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDeleteParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index d970247c..c4f4483f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.ProjectService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all projects. The projects are sorted by creation date, with the most recently-created - * projects coming first + * List out all projects. The projects are sorted by creation date, with the most + * recently-created projects coming first */ -class ProjectListPage -private constructor( +class ProjectListPage private constructor( private val projectsService: ProjectService, private val params: ProjectListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectListPage && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectListPage && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ - override fun toString() = - "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" + override fun toString() = "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectsService.list(it) } + return getNextPageParams().map { projectsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -84,16 +74,18 @@ private constructor( @JvmStatic fun of(projectsService: ProjectService, params: ProjectListParams, response: Response) = - ProjectListPage(projectsService, params, response) + ProjectListPage( + projectsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -107,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ProjectListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -143,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectListPage) : Iterable { + class AutoPager( + private val firstPage: ProjectListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 2ef21803..324a224f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.ProjectServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all projects. The projects are sorted by creation date, with the most recently-created - * projects coming first + * List out all projects. The projects are sorted by creation date, with the most + * recently-created projects coming first */ -class ProjectListPageAsync -private constructor( +class ProjectListPageAsync private constructor( private val projectsService: ProjectServiceAsync, private val params: ProjectListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectListPageAsync && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectListPageAsync && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ - override fun toString() = - "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" + override fun toString() = "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { projectsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + projectsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,20 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectsService: ProjectServiceAsync, - params: ProjectListParams, - response: Response, - ) = ProjectListPageAsync(projectsService, params, response) + fun of(projectsService: ProjectServiceAsync, params: ProjectListParams, response: Response) = + ProjectListPageAsync( + projectsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -112,34 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** Returns a mutable builder for constructing an instance of [ProjectListPageAsync]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ProjectListPageAsync]. + */ + @JvmStatic + fun builder() = Builder() } class Builder { @@ -148,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectListPageAsync) { + class AutoPager( + private val firstPage: ProjectListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Project) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Project) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index c011f50b..539d3cbe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all projects. The projects are sorted by creation date, with the most recently-created - * projects coming first + * List out all projects. The projects are sorted by creation date, with the most + * recently-created projects coming first */ -class ProjectListParams -private constructor( +class ProjectListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -36,20 +35,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,51 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ProjectListParams = builder().build() + @JvmStatic + fun none(): ProjectListParams = builder().build() /** Returns a mutable builder for constructing an instance of [ProjectListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectListParams]. */ @@ -113,61 +139,71 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectListParams: ProjectListParams) = apply { - endingBefore = projectListParams.endingBefore - ids = projectListParams.ids - limit = projectListParams.limit - orgName = projectListParams.orgName - projectName = projectListParams.projectName - startingAfter = projectListParams.startingAfter - additionalHeaders = projectListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectListParams.additionalQueryParams.toBuilder() - } + internal fun from(projectListParams: ProjectListParams) = + apply { + endingBefore = projectListParams.endingBefore + ids = projectListParams.ids + limit = projectListParams.limit + orgName = projectListParams.orgName + projectName = projectListParams.projectName + startingAfter = projectListParams.startingAfter + additionalHeaders = projectListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -176,13 +212,19 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) @@ -190,144 +232,172 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectListParams = ProjectListParams( - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -345,19 +415,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -372,12 +442,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -387,60 +462,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index ea2b6b82..e82d4edf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Log feedback for a set of project logs events */ -class ProjectLogFeedbackParams -private constructor( +class ProjectLogFeedbackParams private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("feedback") - @ExcludeMissing - private val feedback: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of project logs feedback items */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - feedback().forEach { it.validate() } - validated = true - } + feedback().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - feedback = body.feedback.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of project logs feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) /** A list of project logs feedback items */ - fun feedback(feedback: JsonField>) = apply { - this.feedback = feedback.map { it.toMutableList() } - } + fun feedback(feedback: JsonField>) = + apply { + this.feedback = feedback.map { it.toMutableList() } + } /** A list of project logs feedback items */ - fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { - this.feedback = - (this.feedback ?: JsonField.of(mutableListOf())).also { + fun addFeedback(feedback: FeedbackProjectLogsItem) = + apply { + this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { checkKnown("feedback", it).add(feedback) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("feedback", feedback).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "feedback", feedback + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -174,8 +184,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -183,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectLogFeedbackParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectLogFeedbackParams]. * * The following fields are required: + * * ```java * .projectId() * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogFeedbackParams]. */ @@ -204,163 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogFeedbackParams: ProjectLogFeedbackParams) = apply { - projectId = projectLogFeedbackParams.projectId - body = projectLogFeedbackParams.body.toBuilder() - additionalHeaders = projectLogFeedbackParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogFeedbackParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogFeedbackParams: ProjectLogFeedbackParams) = + apply { + projectId = projectLogFeedbackParams.projectId + body = projectLogFeedbackParams.body.toBuilder() + additionalHeaders = projectLogFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFeedbackParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** A list of project logs feedback items */ - fun feedback(feedback: List) = apply { body.feedback(feedback) } + fun feedback(feedback: List) = + apply { + body.feedback(feedback) + } /** A list of project logs feedback items */ - fun feedback(feedback: JsonField>) = apply { - body.feedback(feedback) - } + fun feedback(feedback: JsonField>) = + apply { + body.feedback(feedback) + } /** A list of project logs feedback items */ - fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { body.addFeedback(feedback) } + fun addFeedback(feedback: FeedbackProjectLogsItem) = + apply { + body.addFeedback(feedback) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( - checkRequired("projectId", projectId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectLogFeedbackParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectLogFeedbackParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 1d82f560..6576d624 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -12,12 +12,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the POST form of the same + * path, but with the parameters in the URL query rather than in the request body. + * For more complex queries, use the `POST /btql` endpoint. */ -class ProjectLogFetchParams -private constructor( +class ProjectLogFetchParams private constructor( private val projectId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -25,6 +24,7 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -33,52 +33,55 @@ private constructor( /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version) @@ -89,20 +92,36 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.maxRootSpanId?.let { + queryParams.put( + "max_root_span_id", listOf(it.toString()) + ) + } + this.maxXactId?.let { + queryParams.put( + "max_xact_id", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -110,14 +129,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectLogFetchParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectLogFetchParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogFetchParams]. */ @@ -133,263 +155,310 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogFetchParams: ProjectLogFetchParams) = apply { - projectId = projectLogFetchParams.projectId - limit = projectLogFetchParams.limit - maxRootSpanId = projectLogFetchParams.maxRootSpanId - maxXactId = projectLogFetchParams.maxXactId - version = projectLogFetchParams.version - additionalHeaders = projectLogFetchParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogFetchParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogFetchParams: ProjectLogFetchParams) = + apply { + projectId = projectLogFetchParams.projectId + limit = projectLogFetchParams.limit + maxRootSpanId = projectLogFetchParams.maxRootSpanId + maxXactId = projectLogFetchParams.maxXactId + version = projectLogFetchParams.version + additionalHeaders = projectLogFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFetchParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String?) = + apply { + this.maxXactId = maxXactId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogFetchParams = ProjectLogFetchParams( - checkRequired("projectId", projectId), - limit, - maxRootSpanId, - maxXactId, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + limit, + maxRootSpanId, + maxXactId, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogFetchParams && projectId == other.projectId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchParams && projectId == other.projectId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 4eb11877..aa9256e2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -22,138 +22,146 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ -class ProjectLogFetchPostParams -private constructor( +class ProjectLogFetchPostParams private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ fun projectId(): String = projectId /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = body.cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = body.limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = body.maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = body.maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun _cursor(): JsonField = body._cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxXactId(): JsonField = body._maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun _version(): JsonField = body._version() @@ -163,169 +171,168 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), - @JsonProperty("limit") - @ExcludeMissing - private val limit: JsonField = JsonMissing.of(), - @JsonProperty("max_root_span_id") - @ExcludeMissing - private val maxRootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("max_xact_id") - @ExcludeMissing - private val maxXactId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") @ExcludeMissing private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") @ExcludeMissing private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(): Optional = - Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(): Optional = - Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + @JsonProperty("limit") + @ExcludeMissing + fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId + @JsonProperty("max_xact_id") + @ExcludeMissing + fun _maxXactId(): JsonField = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -333,25 +340,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true } - cursor() - limit() - maxRootSpanId() - maxXactId() - version() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -365,261 +374,284 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - cursor = body.cursor - limit = body.limit - maxRootSpanId = body.maxRootSpanId - maxXactId = body.maxXactId - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { this.limit = limit } + fun limit(limit: JsonField) = + apply { + this.limit = limit + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: JsonField) = + apply { + this.maxXactId = maxXactId + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: String?) = version(JsonField.ofNullable(version)) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun version(version: JsonField) = + apply { + this.version = version + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toImmutable(), + cursor, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -628,8 +660,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -637,14 +668,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectLogFetchPostParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectLogFetchPostParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogFetchPostParams]. */ @@ -657,358 +691,431 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = apply { - projectId = projectLogFetchPostParams.projectId - body = projectLogFetchPostParams.body.toBuilder() - additionalHeaders = projectLogFetchPostParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogFetchPostParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = + apply { + projectId = projectLogFetchPostParams.projectId + body = projectLogFetchPostParams.body.toBuilder() + additionalHeaders = projectLogFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFetchPostParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: String?) = apply { body.cursor(cursor) } + fun cursor(cursor: String?) = + apply { + body.cursor(cursor) + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } + fun cursor(cursor: JsonField) = + apply { + body.cursor(cursor) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { body.limit(limit) } + fun limit(limit: Long?) = + apply { + body.limit(limit) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { body.limit(limit) } + fun limit(limit: JsonField) = + apply { + body.limit(limit) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: String?) = + apply { + body.maxXactId(maxXactId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: JsonField) = + apply { + body.maxXactId(maxXactId) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { body.version(version) } + fun version(version: String?) = + apply { + body.version(version) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { body.version(version) } + fun version(version: JsonField) = + apply { + body.version(version) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogFetchPostParams = ProjectLogFetchPostParams( - checkRequired("projectId", projectId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectLogFetchPostParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectLogFetchPostParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 00032977..d3e46403 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Insert a set of events into the project logs */ -class ProjectLogInsertParams -private constructor( +class ProjectLogInsertParams private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of project logs events to insert */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - validated = true - } + events().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - events = body.events.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of project logs events to insert */ fun events(events: List) = events(JsonField.of(events)) /** A list of project logs events to insert */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of project logs events to insert */ - fun addEvent(event: InsertProjectLogsEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: InsertProjectLogsEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("events", events).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -182,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectLogInsertParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectLogInsertParams]. * * The following fields are required: + * * ```java * .projectId() * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogInsertParams]. */ @@ -203,161 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogInsertParams: ProjectLogInsertParams) = apply { - projectId = projectLogInsertParams.projectId - body = projectLogInsertParams.body.toBuilder() - additionalHeaders = projectLogInsertParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogInsertParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogInsertParams: ProjectLogInsertParams) = + apply { + projectId = projectLogInsertParams.projectId + body = projectLogInsertParams.body.toBuilder() + additionalHeaders = projectLogInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogInsertParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** A list of project logs events to insert */ - fun events(events: List) = apply { body.events(events) } + fun events(events: List) = + apply { + body.events(events) + } /** A list of project logs events to insert */ - fun events(events: JsonField>) = apply { body.events(events) } + fun events(events: JsonField>) = + apply { + body.events(events) + } /** A list of project logs events to insert */ - fun addEvent(event: InsertProjectLogsEvent) = apply { body.addEvent(event) } + fun addEvent(event: InsertProjectLogsEvent) = + apply { + body.addEvent(event) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogInsertParams = ProjectLogInsertParams( - checkRequired("projectId", projectId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectLogInsertParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectLogInsertParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 94a6ee65..f1bc7509 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -23,71 +23,43 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ProjectLogsEvent -@JsonCreator -private constructor( +class ProjectLogsEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - private val context: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("is_root") - @ExcludeMissing - private val isRoot: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") - @ExcludeMissing - private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the project logs (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the project logs (see the + * `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -107,51 +79,62 @@ private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different project logs events together as part + * of a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error + @JsonProperty("error") + @ExcludeMissing + fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** Whether this span is a root span */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) @@ -159,113 +142,147 @@ private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + @JsonProperty("output") + @ExcludeMissing + fun _output(): JsonValue = output /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * An array of the parent `span_ids` of this project logs event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the project logs (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the project logs (see the + * `version` parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId + @JsonProperty("log_id") + @ExcludeMissing + fun _logId(): JsonField = logId /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the project */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** A unique identifier for the trace this project logs event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different project logs events together as part + * of a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context /** Whether this span is a root span */ - @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot + @JsonProperty("is_root") + @ExcludeMissing + fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -273,15 +290,18 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * An array of the parent `span_ids` of this project logs event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -289,30 +309,31 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectLogsEvent = apply { - if (validated) { - return@apply - } + fun validate(): ProjectLogsEvent = + apply { + if (validated) { + return@apply + } - id() - _xactId() - created() - logId() - orgId() - projectId() - rootSpanId() - spanId() - context().ifPresent { it.validate() } - isRoot() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanParents() - tags() - validated = true - } + id() + _xactId() + created() + logId() + orgId() + projectId() + rootSpanId() + spanId() + context().ifPresent { it.validate() } + isRoot() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -322,6 +343,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectLogsEvent]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -333,7 +355,8 @@ private constructor( * .spanId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogsEvent]. */ @@ -363,139 +386,184 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectLogsEvent: ProjectLogsEvent) = apply { - id = projectLogsEvent.id - _xactId = projectLogsEvent._xactId - created = projectLogsEvent.created - logId = projectLogsEvent.logId - orgId = projectLogsEvent.orgId - projectId = projectLogsEvent.projectId - rootSpanId = projectLogsEvent.rootSpanId - spanId = projectLogsEvent.spanId - context = projectLogsEvent.context - error = projectLogsEvent.error - expected = projectLogsEvent.expected - input = projectLogsEvent.input - isRoot = projectLogsEvent.isRoot - metadata = projectLogsEvent.metadata - metrics = projectLogsEvent.metrics - origin = projectLogsEvent.origin - output = projectLogsEvent.output - scores = projectLogsEvent.scores - spanAttributes = projectLogsEvent.spanAttributes - spanParents = projectLogsEvent.spanParents.map { it.toMutableList() } - tags = projectLogsEvent.tags.map { it.toMutableList() } - additionalProperties = projectLogsEvent.additionalProperties.toMutableMap() - } + internal fun from(projectLogsEvent: ProjectLogsEvent) = + apply { + id = projectLogsEvent.id + _xactId = projectLogsEvent._xactId + created = projectLogsEvent.created + logId = projectLogsEvent.logId + orgId = projectLogsEvent.orgId + projectId = projectLogsEvent.projectId + rootSpanId = projectLogsEvent.rootSpanId + spanId = projectLogsEvent.spanId + context = projectLogsEvent.context + error = projectLogsEvent.error + expected = projectLogsEvent.expected + input = projectLogsEvent.input + isRoot = projectLogsEvent.isRoot + metadata = projectLogsEvent.metadata + metrics = projectLogsEvent.metrics + origin = projectLogsEvent.origin + output = projectLogsEvent.output + scores = projectLogsEvent.scores + spanAttributes = projectLogsEvent.spanAttributes + spanParents = projectLogsEvent.spanParents.map { it.toMutableList() } + tags = projectLogsEvent.tags.map { it.toMutableList() } + additionalProperties = projectLogsEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the project logs (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the project logs (see the + * `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the project logs (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the project logs (see the + * `version` parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the project logs event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** A literal 'g' which identifies the log as a project log */ fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'g' which identifies the log as a project log */ - fun logId(logId: JsonField) = apply { this.logId = logId } + fun logId(logId: JsonField) = + apply { + this.logId = logId + } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique id for the organization that the project belongs under */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the project */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** A unique identifier for the trace this project logs event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** A unique identifier for the trace this project logs event belongs to */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different project logs events together as part + * of a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different project logs events together as part + * of a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = + apply { + this.context = context + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = + apply { + this.error = error + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) @@ -507,55 +575,64 @@ private constructor( fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ - fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + fun isRoot(isRoot: JsonField) = + apply { + this.isRoot = isRoot + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** Indicates the event was copied from another object. */ fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) @@ -564,97 +641,109 @@ private constructor( fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = + apply { + this.output = output + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = - spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = + apply { + this.spanAttributes = spanAttributes + } /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -663,73 +752,104 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectLogsEvent = ProjectLogsEvent( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("created", created), - checkRequired("logId", logId), - checkRequired("orgId", orgId), - checkRequired("projectId", projectId), - checkRequired("rootSpanId", rootSpanId), - checkRequired("spanId", spanId), - context, - error, - expected, - input, - isRoot, - metadata, - metrics, - origin, - output, - scores, - spanAttributes, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "created", created + ), + checkRequired( + "logId", logId + ), + checkRequired( + "orgId", orgId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "rootSpanId", rootSpanId + ), + checkRequired( + "spanId", spanId + ), + context, + error, + expected, + input, + isRoot, + metadata, + metrics, + origin, + output, + scores, + spanAttributes, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** A literal 'g' which identifies the log as a project log */ - class LogId @JsonCreator private constructor(private val value: JsonField) : Enum { + class LogId @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -740,16 +860,18 @@ private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - G + G, } /** * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LogId] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -759,11 +881,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -774,11 +896,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -789,23 +911,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -814,38 +933,28 @@ private constructor( } /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ @NoAutoDetect - class Context - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Context @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -868,23 +977,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Context = apply { - if (validated) { - return@apply - } + fun validate(): Context = + apply { + if (validated) { + return@apply + } - callerFilename() - callerFunctionname() - callerLineno() - validated = true - } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Context]. */ @@ -896,38 +1007,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = + apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String?) = - callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = + apply { + this.callerFilename = callerFilename + } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String?) = - callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = + apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -939,44 +1049,52 @@ private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = + apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -985,23 +1103,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1010,20 +1125,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1032,38 +1149,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1076,38 +1201,22 @@ private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - private val completionTokens: JsonField = JsonMissing.of(), + class Metrics @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") - @ExcludeMissing - private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") - @ExcludeMissing - private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** This metric is deprecated */ @@ -1121,31 +1230,31 @@ private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1153,35 +1262,41 @@ private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ - @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end + @JsonProperty("end") + @ExcludeMissing + fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ - @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + @JsonProperty("start") + @ExcludeMissing + fun _start(): JsonField = start /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1189,25 +1304,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true - } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1224,133 +1341,144 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = + apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = + apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = + apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun callerLineno(callerLineno: JsonValue) = + apply { + this.callerLineno = callerLineno + } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long?) = - completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long) = - completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = + apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ - fun end(end: JsonField) = apply { this.end = end } + fun end(end: JsonField) = + apply { + this.end = end + } /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = + apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = + apply { + this.start = start + } /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1362,47 +1490,57 @@ private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = + apply { + this.tokens = tokens + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1411,27 +1549,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** Indicates the event was copied from another object. */ @NoAutoDetect - class Origin - @JsonCreator - private constructor( + class Origin @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** ID of the original event. */ @@ -1447,13 +1576,19 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** Type of the object the event is originating from. */ @JsonProperty("object_type") @@ -1466,17 +1601,18 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - id() - _xactId() - objectId() - objectType() - validated = true - } + id() + _xactId() + objectId() + objectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1486,6 +1622,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -1493,7 +1630,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -1506,82 +1644,111 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() + } /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalProperties.toImmutable(), ) } /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1614,9 +1781,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1637,8 +1806,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1658,7 +1827,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1677,20 +1846,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1699,11 +1865,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1712,25 +1878,23 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1739,20 +1903,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1761,38 +1927,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1805,11 +1979,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogsEvent && id == other.id && _xactId == other._xactId && created == other.created && logId == other.logId && orgId == other.orgId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogsEvent && id == other.id && _xactId == other._xactId && created == other.created && logId == other.logId && orgId == other.orgId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1818,6 +1992,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, logId=$logId, orgId=$orgId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, logId=$logId, orgId=$orgId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index 6694a858..d66db835 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a project object by its id */ -class ProjectRetrieveParams -private constructor( +class ProjectRetrieveParams private constructor( private val projectId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectRetrieveParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectRetrieveParams: ProjectRetrieveParams) = apply { - projectId = projectRetrieveParams.projectId - additionalHeaders = projectRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = projectRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(projectRetrieveParams: ProjectRetrieveParams) = + apply { + projectId = projectRetrieveParams.projectId + additionalHeaders = projectRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectRetrieveParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectRetrieveParams = ProjectRetrieveParams( - checkRequired("projectId", projectId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectRetrieveParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectRetrieveParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt index 6144049c..2ebce579 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt @@ -31,38 +31,24 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** A project score is a user-configured score, which can be manually-labeled through the UI */ +/** + * A project score is a user-configured score, which can be manually-labeled + * through the UI + */ @NoAutoDetect -class ProjectScore -@JsonCreator -private constructor( +class ProjectScore @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("score_type") - @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("categories") - @ExcludeMissing - private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - private val config: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the project score */ @@ -80,8 +66,7 @@ private constructor( fun userId(): String = userId.getRequired("user_id") /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = - Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) fun config(): Optional = Optional.ofNullable(config.getNullable("config")) @@ -89,41 +74,64 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the project score */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ fun position(): Optional = Optional.ofNullable(position.getNullable("position")) /** Unique identifier for the project score */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** The type of the configured score */ - @JsonProperty("score_type") @ExcludeMissing fun _scoreType(): JsonField = scoreType + @JsonProperty("score_type") + @ExcludeMissing + fun _scoreType(): JsonField = scoreType - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @ExcludeMissing fun _categories(): JsonField = categories - @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField = config /** Date of project score creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Textual description of the project score */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ - @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position @JsonAnyGetter @ExcludeMissing @@ -131,23 +139,24 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectScore = apply { - if (validated) { - return@apply - } + fun validate(): ProjectScore = + apply { + if (validated) { + return@apply + } - id() - name() - projectId() - scoreType() - userId() - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - created() - description() - position() - validated = true - } + id() + name() + projectId() + scoreType() + userId() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + created() + description() + position() + validated = true + } fun toBuilder() = Builder().from(this) @@ -157,6 +166,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectScore]. * * The following fields are required: + * * ```java * .id() * .name() @@ -165,7 +175,8 @@ private constructor( * .userId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScore]. */ @@ -184,57 +195,75 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScore: ProjectScore) = apply { - id = projectScore.id - name = projectScore.name - projectId = projectScore.projectId - scoreType = projectScore.scoreType - userId = projectScore.userId - categories = projectScore.categories - config = projectScore.config - created = projectScore.created - description = projectScore.description - position = projectScore.position - additionalProperties = projectScore.additionalProperties.toMutableMap() - } + internal fun from(projectScore: ProjectScore) = + apply { + id = projectScore.id + name = projectScore.name + projectId = projectScore.projectId + scoreType = projectScore.scoreType + userId = projectScore.userId + categories = projectScore.categories + config = projectScore.config + created = projectScore.created + description = projectScore.description + position = projectScore.position + additionalProperties = projectScore.additionalProperties.toMutableMap() + } /** Unique identifier for the project score */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project score */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = + apply { + this.scoreType = scoreType + } fun userId(userId: String) = userId(JsonField.of(userId)) - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { this.categories = categories } + fun categories(categories: JsonField) = + apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) @@ -243,14 +272,16 @@ private constructor( fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { this.config = config } + fun config(config: JsonField) = + apply { + this.config = config + } /** Date of project score creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -259,7 +290,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of project score creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -268,64 +302,100 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ fun position(position: String?) = position(JsonField.ofNullable(position)) - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ fun position(position: Optional) = position(position.getOrNull()) - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ - fun position(position: JsonField) = apply { this.position = position } + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ + fun position(position: JsonField) = + apply { + this.position = position + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectScore = ProjectScore( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("scoreType", scoreType), - checkRequired("userId", userId), - categories, - config, - created, - description, - position, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "scoreType", scoreType + ), + checkRequired( + "userId", userId + ), + categories, + config, + created, + description, + position, + additionalProperties.toImmutable(), ) } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ScoreType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -358,9 +428,11 @@ private constructor( * An enum containing [ScoreType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ScoreType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -371,17 +443,18 @@ private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown value. + * An enum member indicating that [ScoreType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -397,11 +470,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -417,23 +490,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -444,13 +514,13 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( + class Categories private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { /** For categorical-type project scores, the list of all categories */ @@ -486,48 +556,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = apply { - if (validated) { - return@apply - } + fun validate(): Categories = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) {} + override fun visitMinimum(minimum: List) { + + } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -546,22 +617,23 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = - Categories(categorical = categorical) + fun ofCategorical(categorical: List) = Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic + fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic + fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of type [T]. + * An interface that defines how to map each variant of [Categories] to a value of + * type [T]. */ interface Visitor { @@ -579,70 +651,59 @@ private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [Categories] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Weighted @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -651,20 +712,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Weighted = apply { - if (validated) { - return@apply - } + fun validate(): Weighted = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -673,41 +736,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = + apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -720,11 +788,9 @@ private constructor( } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -733,20 +799,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -755,41 +823,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -803,11 +876,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScore && id == other.id && name == other.name && projectId == other.projectId && scoreType == other.scoreType && userId == other.userId && categories == other.categories && config == other.config && created == other.created && description == other.description && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScore && id == other.id && name == other.name && projectId == other.projectId && scoreType == other.scoreType && userId == other.userId && categories == other.categories && config == other.config && created == other.created && description == other.description && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -816,6 +889,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectScore{id=$id, name=$name, projectId=$projectId, scoreType=$scoreType, userId=$userId, categories=$categories, config=$config, created=$created, description=$description, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScore{id=$id, name=$name, projectId=$projectId, scoreType=$scoreType, userId=$userId, categories=$categories, config=$config, created=$created, description=$description, position=$position, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index 9637cd01..cc936db0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -18,12 +18,11 @@ import java.util.Objects /** For categorical-type project scores, defines a single category */ @NoAutoDetect -class ProjectScoreCategory -@JsonCreator -private constructor( +class ProjectScoreCategory @JsonCreator private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the category */ @@ -33,10 +32,14 @@ private constructor( fun value(): Double = value.getRequired("value") /** Name of the category */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -44,30 +47,34 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectScoreCategory = apply { - if (validated) { - return@apply - } + fun validate(): ProjectScoreCategory = + apply { + if (validated) { + return@apply + } - name() - value() - validated = true - } + name() + value() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreCategory]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreCategory]. * * The following fields are required: + * * ```java * .name() * .value() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreCategory]. */ @@ -78,57 +85,75 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreCategory: ProjectScoreCategory) = apply { - name = projectScoreCategory.name - value = projectScoreCategory.value - additionalProperties = projectScoreCategory.additionalProperties.toMutableMap() - } + internal fun from(projectScoreCategory: ProjectScoreCategory) = + apply { + name = projectScoreCategory.name + value = projectScoreCategory.value + additionalProperties = projectScoreCategory.additionalProperties.toMutableMap() + } /** Name of the category */ fun name(name: String) = name(JsonField.of(name)) /** Name of the category */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Numerical value of the category. Must be between 0 and 1, inclusive */ fun value(value: Double) = value(JsonField.of(value)) /** Numerical value of the category. Must be between 0 and 1, inclusive */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = + apply { + this.value = value + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectScoreCategory = ProjectScoreCategory( - checkRequired("name", name), - checkRequired("value", value), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "value", value + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreCategory && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCategory && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -137,6 +162,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 82cf7754..5650b1eb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -20,26 +20,17 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ProjectScoreConfig -@JsonCreator -private constructor( - @JsonProperty("destination") - @ExcludeMissing - private val destination: JsonField = JsonMissing.of(), - @JsonProperty("multi_select") - @ExcludeMissing - private val multiSelect: JsonField = JsonMissing.of(), - @JsonProperty("online") - @ExcludeMissing - private val online: JsonField = JsonMissing.of(), +class ProjectScoreConfig @JsonCreator private constructor( + @JsonProperty("destination") @ExcludeMissing private val destination: JsonField = JsonMissing.of(), + @JsonProperty("multi_select") @ExcludeMissing private val multiSelect: JsonField = JsonMissing.of(), + @JsonProperty("online") @ExcludeMissing private val online: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun destination(): Optional = - Optional.ofNullable(destination.getNullable("destination")) + fun destination(): Optional = Optional.ofNullable(destination.getNullable("destination")) - fun multiSelect(): Optional = - Optional.ofNullable(multiSelect.getNullable("multi_select")) + fun multiSelect(): Optional = Optional.ofNullable(multiSelect.getNullable("multi_select")) fun online(): Optional = Optional.ofNullable(online.getNullable("online")) @@ -51,7 +42,9 @@ private constructor( @ExcludeMissing fun _multiSelect(): JsonField = multiSelect - @JsonProperty("online") @ExcludeMissing fun _online(): JsonField = online + @JsonProperty("online") + @ExcludeMissing + fun _online(): JsonField = online @JsonAnyGetter @ExcludeMissing @@ -59,23 +52,25 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectScoreConfig = apply { - if (validated) { - return@apply - } + fun validate(): ProjectScoreConfig = + apply { + if (validated) { + return@apply + } - destination() - multiSelect() - online().ifPresent { it.validate() } - validated = true - } + destination() + multiSelect() + online().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ProjectScoreConfig]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreConfig]. */ @@ -87,20 +82,22 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreConfig: ProjectScoreConfig) = apply { - destination = projectScoreConfig.destination - multiSelect = projectScoreConfig.multiSelect - online = projectScoreConfig.online - additionalProperties = projectScoreConfig.additionalProperties.toMutableMap() - } + internal fun from(projectScoreConfig: ProjectScoreConfig) = + apply { + destination = projectScoreConfig.destination + multiSelect = projectScoreConfig.multiSelect + online = projectScoreConfig.online + additionalProperties = projectScoreConfig.additionalProperties.toMutableMap() + } fun destination(destination: Destination?) = destination(JsonField.ofNullable(destination)) fun destination(destination: Optional) = destination(destination.getOrNull()) - fun destination(destination: JsonField) = apply { - this.destination = destination - } + fun destination(destination: JsonField) = + apply { + this.destination = destination + } fun multiSelect(multiSelect: Boolean?) = multiSelect(JsonField.ofNullable(multiSelect)) @@ -108,49 +105,70 @@ private constructor( fun multiSelect(multiSelect: Optional) = multiSelect(multiSelect.getOrNull()) - fun multiSelect(multiSelect: JsonField) = apply { this.multiSelect = multiSelect } + fun multiSelect(multiSelect: JsonField) = + apply { + this.multiSelect = multiSelect + } fun online(online: OnlineScoreConfig?) = online(JsonField.ofNullable(online)) fun online(online: Optional) = online(online.getOrNull()) - fun online(online: JsonField) = apply { this.online = online } + fun online(online: JsonField) = + apply { + this.online = online + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectScoreConfig = - ProjectScoreConfig(destination, multiSelect, online, additionalProperties.toImmutable()) + ProjectScoreConfig( + destination, + multiSelect, + online, + additionalProperties.toImmutable(), + ) } - class Destination @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Destination @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -161,32 +179,36 @@ private constructor( /** An enum containing [Destination]'s known values. */ enum class Known { - EXPECTED + EXPECTED, } /** - * An enum containing [Destination]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Destination]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [Destination] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { EXPECTED, /** - * An enum member indicating that [Destination] was instantiated with an unknown value. + * An enum member indicating that [Destination] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -197,11 +219,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -212,23 +234,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ + return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -237,11 +256,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreConfig && destination == other.destination && multiSelect == other.multiSelect && online == other.online && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreConfig && destination == other.destination && multiSelect == other.multiSelect && online == other.online && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -250,6 +269,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectScoreConfig{destination=$destination, multiSelect=$multiSelect, online=$online, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreConfig{destination=$destination, multiSelect=$multiSelect, online=$online, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt index 49401ff2..7661dfe8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt @@ -34,14 +34,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new project_score. If there is an existing project_score in the project with the same - * name as the one specified in the request, will return the existing project_score unmodified + * Create a new project_score. If there is an existing project_score in the project + * with the same name as the one specified in the request, will return the existing + * project_score unmodified */ -class ProjectScoreCreateParams -private constructor( +class ProjectScoreCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project score */ @@ -84,37 +85,27 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - /** A project score is a user-configured score, which can be manually-labeled through the UI */ + /** + * A project score is a user-configured score, which can be manually-labeled + * through the UI + */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("score_type") - @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), - @JsonProperty("categories") - @ExcludeMissing - private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - private val config: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project score */ @@ -127,21 +118,22 @@ private constructor( fun scoreType(): ScoreType = scoreType.getRequired("score_type") /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = - Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) - fun config(): Optional = - Optional.ofNullable(config.getNullable("config")) + fun config(): Optional = Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** The type of the configured score */ @JsonProperty("score_type") @@ -168,19 +160,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - projectId() - scoreType() - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - description() - validated = true - } + name() + projectId() + scoreType() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + validated = true + } fun toBuilder() = Builder().from(this) @@ -190,13 +183,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -211,63 +206,73 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - scoreType = body.scoreType - categories = body.categories - config = body.config - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + scoreType = body.scoreType + categories = body.categories + config = body.config + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = + apply { + this.scoreType = scoreType + } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { - this.categories = categories - } + fun categories(categories: JsonField) = + apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = - categories(Categories.ofWeighted(weighted)) + fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = - categories(Categories.ofMinimum(minimum)) + fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { this.config = config } + fun config(config: JsonField) = + apply { + this.config = config + } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -276,47 +281,61 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("scoreType", scoreType), - categories, - config, - description, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "scoreType", scoreType + ), + categories, + config, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -325,8 +344,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -334,16 +352,19 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreCreateParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreCreateParams]. */ @@ -355,204 +376,287 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreCreateParams: ProjectScoreCreateParams) = apply { - body = projectScoreCreateParams.body.toBuilder() - additionalHeaders = projectScoreCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreCreateParams: ProjectScoreCreateParams) = + apply { + body = projectScoreCreateParams.body.toBuilder() + additionalHeaders = projectScoreCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreCreateParams.additionalQueryParams.toBuilder() + } /** Name of the project score */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project score */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: ScoreType) = + apply { + body.scoreType(scoreType) + } /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: JsonField) = + apply { + body.scoreType(scoreType) + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { body.categories(categories) } + fun categories(categories: Categories) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { body.categories(categories) } + fun categories(categories: JsonField) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = apply { - body.categoriesOfCategorical(categorical) - } + fun categoriesOfCategorical(categorical: List) = + apply { + body.categoriesOfCategorical(categorical) + } /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } + fun categories(weighted: Categories.Weighted) = + apply { + body.categories(weighted) + } /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } + fun categoriesOfMinimum(minimum: List) = + apply { + body.categoriesOfMinimum(minimum) + } /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } + fun categories(nullableVariant: Categories.NullableVariant) = + apply { + body.categories(nullableVariant) + } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + fun config(config: ProjectScoreConfig?) = + apply { + body.config(config) + } fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { body.config(config) } + fun config(config: JsonField) = + apply { + body.config(config) + } /** Textual description of the project score */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project score */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreCreateParams = ProjectScoreCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ScoreType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -585,9 +689,11 @@ private constructor( * An enum containing [ScoreType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ScoreType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -598,17 +704,18 @@ private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown value. + * An enum member indicating that [ScoreType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -624,11 +731,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -644,23 +751,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -671,13 +775,13 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( + class Categories private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { /** For categorical-type project scores, the list of all categories */ @@ -713,48 +817,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = apply { - if (validated) { - return@apply - } + fun validate(): Categories = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) {} + override fun visitMinimum(minimum: List) { + + } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -773,22 +878,23 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = - Categories(categorical = categorical) + fun ofCategorical(categorical: List) = Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic + fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic + fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of type [T]. + * An interface that defines how to map each variant of [Categories] to a value of + * type [T]. */ interface Visitor { @@ -806,70 +912,59 @@ private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [Categories] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Weighted @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -878,20 +973,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Weighted = apply { - if (validated) { - return@apply - } + fun validate(): Weighted = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -900,41 +997,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = + apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -947,11 +1049,9 @@ private constructor( } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -960,20 +1060,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -982,41 +1084,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1030,15 +1137,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 291b304d..1ddf0990 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a project_score object by its id */ -class ProjectScoreDeleteParams -private constructor( +class ProjectScoreDeleteParams private constructor( private val projectScoreId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** ProjectScore id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreDeleteParams]. * * The following fields are required: + * * ```java * .projectScoreId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreDeleteParams: ProjectScoreDeleteParams) = apply { - projectScoreId = projectScoreDeleteParams.projectScoreId - additionalHeaders = projectScoreDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectScoreDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(projectScoreDeleteParams: ProjectScoreDeleteParams) = + apply { + projectScoreId = projectScoreDeleteParams.projectScoreId + additionalHeaders = projectScoreDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectScoreDeleteParams.additionalBodyProperties.toMutableMap() + } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun projectScoreId(projectScoreId: String) = + apply { + this.projectScoreId = projectScoreId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( - checkRequired("projectScoreId", projectScoreId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "projectScoreId", projectScoreId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreDeleteParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreDeleteParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index f0864a38..e082c718 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.ProjectScoreService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ -class ProjectScoreListPage -private constructor( +class ProjectScoreListPage private constructor( private val projectScoresService: ProjectScoreService, private val params: ProjectScoreListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreListPage && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListPage && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ - override fun toString() = - "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" + override fun toString() = "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectScoreListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectScoreListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectScoresService.list(it) } + return getNextPageParams().map { projectScoresService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectScoresService: ProjectScoreService, - params: ProjectScoreListParams, - response: Response, - ) = ProjectScoreListPage(projectScoresService, params, response) + fun of(projectScoresService: ProjectScoreService, params: ProjectScoreListParams, response: Response) = + ProjectScoreListPage( + projectScoresService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** Returns a mutable builder for constructing an instance of [ProjectScoreListPage]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ProjectScoreListPage]. + */ + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +139,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectScoreListPage) : Iterable { + class AutoPager( + private val firstPage: ProjectScoreListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index f3328758..342ba7fe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.ProjectScoreServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ -class ProjectScoreListPageAsync -private constructor( +class ProjectScoreListPageAsync private constructor( private val projectScoresService: ProjectScoreServiceAsync, private val params: ProjectScoreListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreListPageAsync && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListPageAsync && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ - override fun toString() = - "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" + override fun toString() = "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectScoreListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectScoreListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { projectScoresService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + projectScoresService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectScoresService: ProjectScoreServiceAsync, - params: ProjectScoreListParams, - response: Response, - ) = ProjectScoreListPageAsync(projectScoresService, params, response) + fun of(projectScoresService: ProjectScoreServiceAsync, params: ProjectScoreListParams, response: Response) = + ProjectScoreListPageAsync( + projectScoresService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,29 +106,29 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -143,7 +136,8 @@ private constructor( * Returns a mutable builder for constructing an instance of * [ProjectScoreListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -152,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectScoreListPageAsync) { + class AutoPager( + private val firstPage: ProjectScoreListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (ProjectScore) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (ProjectScore) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt index 6f86bc5e..879f1efa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt @@ -26,11 +26,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ -class ProjectScoreListParams -private constructor( +class ProjectScoreListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -42,20 +41,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -80,9 +80,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -93,28 +93,69 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.projectScoreName?.let { queryParams.put("project_score_name", listOf(it.toString())) } - this.scoreType?.let { queryParams.put("score_type", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.projectScoreName?.let { + queryParams.put( + "project_score_name", listOf(it.toString()) + ) + } + this.scoreType?.let { + queryParams.put( + "score_type", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ProjectScoreListParams = builder().build() + @JvmStatic + fun none(): ProjectScoreListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [ProjectScoreListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ProjectScoreListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreListParams]. */ @@ -134,64 +175,74 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreListParams: ProjectScoreListParams) = apply { - endingBefore = projectScoreListParams.endingBefore - ids = projectScoreListParams.ids - limit = projectScoreListParams.limit - orgName = projectScoreListParams.orgName - projectId = projectScoreListParams.projectId - projectName = projectScoreListParams.projectName - projectScoreName = projectScoreListParams.projectScoreName - scoreType = projectScoreListParams.scoreType - startingAfter = projectScoreListParams.startingAfter - additionalHeaders = projectScoreListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreListParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreListParams: ProjectScoreListParams) = + apply { + endingBefore = projectScoreListParams.endingBefore + ids = projectScoreListParams.ids + limit = projectScoreListParams.limit + orgName = projectScoreListParams.orgName + projectId = projectScoreListParams.projectId + projectName = projectScoreListParams.projectName + projectScoreName = projectScoreListParams.projectScoreName + scoreType = projectScoreListParams.scoreType + startingAfter = projectScoreListParams.startingAfter + additionalHeaders = projectScoreListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -200,34 +251,46 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_score to search for */ - fun projectScoreName(projectScoreName: String?) = apply { - this.projectScoreName = projectScoreName - } + fun projectScoreName(projectScoreName: String?) = + apply { + this.projectScoreName = projectScoreName + } /** Name of the project_score to search for */ - fun projectScoreName(projectScoreName: Optional) = - projectScoreName(projectScoreName.getOrNull()) + fun projectScoreName(projectScoreName: Optional) = projectScoreName(projectScoreName.getOrNull()) /** The type of the configured score */ - fun scoreType(scoreType: ScoreType?) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType?) = + apply { + this.scoreType = scoreType + } /** The type of the configured score */ fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) @@ -236,153 +299,180 @@ private constructor( fun scoreType(project: ScoreType.ProjectScoreType) = scoreType(ScoreType.ofProject(project)) /** The type of the configured score */ - fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = - scoreType(ScoreType.ofProjectScoreTypes(projectScoreTypes)) + fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = scoreType(ScoreType.ofProjectScoreTypes(projectScoreTypes)) /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreListParams = ProjectScoreListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectScoreName, - scoreType, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectScoreName, + scoreType, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -400,19 +490,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -427,12 +517,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -442,46 +537,43 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } @@ -489,19 +581,18 @@ private constructor( /** The type of the configured score */ @JsonDeserialize(using = ScoreType.Deserializer::class) @JsonSerialize(using = ScoreType.Serializer::class) - class ScoreType - private constructor( + class ScoreType private constructor( private val project: ProjectScoreType? = null, private val projectScoreTypes: List? = null, private val _json: JsonValue? = null, + ) { /** The type of the configured score */ fun project(): Optional = Optional.ofNullable(project) /** The type of the configured score */ - fun projectScoreTypes(): Optional> = - Optional.ofNullable(projectScoreTypes) + fun projectScoreTypes(): Optional> = Optional.ofNullable(projectScoreTypes) fun isProject(): Boolean = project != null @@ -511,25 +602,24 @@ private constructor( fun asProject(): ProjectScoreType = project.getOrThrow("project") /** The type of the configured score */ - fun asProjectScoreTypes(): List = - projectScoreTypes.getOrThrow("projectScoreTypes") + fun asProjectScoreTypes(): List = projectScoreTypes.getOrThrow("projectScoreTypes") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - project != null -> visitor.visitProject(project) - projectScoreTypes != null -> visitor.visitProjectScoreTypes(projectScoreTypes) - else -> visitor.unknown(_json) - } + return when { + project != null -> visitor.visitProject(project) + projectScoreTypes != null -> visitor.visitProjectScoreTypes(projectScoreTypes) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && project == other.project && projectScoreTypes == other.projectScoreTypes /* spotless:on */ + return /* spotless:off */ other is ScoreType && project == other.project && projectScoreTypes == other.projectScoreTypes /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(project, projectScoreTypes) /* spotless:on */ @@ -545,16 +635,17 @@ private constructor( companion object { /** The type of the configured score */ - @JvmStatic fun ofProject(project: ProjectScoreType) = ScoreType(project = project) + @JvmStatic + fun ofProject(project: ProjectScoreType) = ScoreType(project = project) /** The type of the configured score */ @JvmStatic - fun ofProjectScoreTypes(projectScoreTypes: List) = - ScoreType(projectScoreTypes = projectScoreTypes) + fun ofProjectScoreTypes(projectScoreTypes: List) = ScoreType(projectScoreTypes = projectScoreTypes) } /** - * An interface that defines how to map each variant of [ScoreType] to a value of type [T]. + * An interface that defines how to map each variant of [ScoreType] to a value of + * type [T]. */ interface Visitor { @@ -567,65 +658,62 @@ private constructor( /** * Maps an unknown variant of [ScoreType] to a value of type [T]. * - * An instance of [ScoreType] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [ScoreType] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ScoreType: $json") + throw BraintrustInvalidDataException("Unknown ScoreType: $json") } } internal class Deserializer : BaseDeserializer(ScoreType::class) { override fun ObjectCodec.deserialize(node: JsonNode): ScoreType { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ScoreType(project = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return ScoreType(projectScoreTypes = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return ScoreType(project = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return ScoreType(projectScoreTypes = it, _json = json) + } - return ScoreType(_json = json) + return ScoreType(_json = json) } } internal class Serializer : BaseSerializer(ScoreType::class) { - override fun serialize( - value: ScoreType, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.project != null -> generator.writeObject(value.project) - value.projectScoreTypes != null -> - generator.writeObject(value.projectScoreTypes) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ScoreType") - } + override fun serialize(value: ScoreType, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.project != null -> generator.writeObject(value.project) + value.projectScoreTypes != null -> generator.writeObject(value.projectScoreTypes) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ScoreType") + } } } /** The type of the configured score */ - class ProjectScoreType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class ProjectScoreType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -658,10 +746,13 @@ private constructor( * An enum containing [ProjectScoreType]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [ProjectScoreType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * An instance of [ProjectScoreType] can contain an unknown value in a couple of + * cases: + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -682,8 +773,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -703,7 +794,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -722,20 +813,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -744,19 +832,21 @@ private constructor( } /** The type of the configured score */ - class ProjectScoreType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class ProjectScoreType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -789,10 +879,13 @@ private constructor( * An enum containing [ProjectScoreType]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [ProjectScoreType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * An instance of [ProjectScoreType] can contain an unknown value in a couple of + * cases: + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -813,8 +906,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -834,7 +927,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -853,20 +946,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -876,15 +966,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectScoreName == other.projectScoreName && scoreType == other.scoreType && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectScoreName == other.projectScoreName && scoreType == other.scoreType && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt index 8373825d..5a2bad2d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt @@ -34,15 +34,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace project_score. If there is an existing project_score in the project with the - * same name as the one specified in the request, will replace the existing project_score with the - * provided fields + * Create or replace project_score. If there is an existing project_score in the + * project with the same name as the one specified in the request, will replace the + * existing project_score with the provided fields */ -class ProjectScoreReplaceParams -private constructor( +class ProjectScoreReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project score */ @@ -85,37 +85,27 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - /** A project score is a user-configured score, which can be manually-labeled through the UI */ + /** + * A project score is a user-configured score, which can be manually-labeled + * through the UI + */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("score_type") - @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), - @JsonProperty("categories") - @ExcludeMissing - private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - private val config: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project score */ @@ -128,21 +118,22 @@ private constructor( fun scoreType(): ScoreType = scoreType.getRequired("score_type") /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = - Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) - fun config(): Optional = - Optional.ofNullable(config.getNullable("config")) + fun config(): Optional = Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** The type of the configured score */ @JsonProperty("score_type") @@ -169,19 +160,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - projectId() - scoreType() - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - description() - validated = true - } + name() + projectId() + scoreType() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + validated = true + } fun toBuilder() = Builder().from(this) @@ -191,13 +183,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -212,63 +206,73 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - scoreType = body.scoreType - categories = body.categories - config = body.config - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + scoreType = body.scoreType + categories = body.categories + config = body.config + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = + apply { + this.scoreType = scoreType + } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { - this.categories = categories - } + fun categories(categories: JsonField) = + apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = - categories(Categories.ofWeighted(weighted)) + fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = - categories(Categories.ofMinimum(minimum)) + fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { this.config = config } + fun config(config: JsonField) = + apply { + this.config = config + } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -277,47 +281,61 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("scoreType", scoreType), - categories, - config, - description, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "scoreType", scoreType + ), + categories, + config, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -326,8 +344,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -335,16 +352,19 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreReplaceParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreReplaceParams]. */ @@ -356,204 +376,287 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreReplaceParams: ProjectScoreReplaceParams) = apply { - body = projectScoreReplaceParams.body.toBuilder() - additionalHeaders = projectScoreReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreReplaceParams: ProjectScoreReplaceParams) = + apply { + body = projectScoreReplaceParams.body.toBuilder() + additionalHeaders = projectScoreReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the project score */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project score */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: ScoreType) = + apply { + body.scoreType(scoreType) + } /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: JsonField) = + apply { + body.scoreType(scoreType) + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { body.categories(categories) } + fun categories(categories: Categories) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { body.categories(categories) } + fun categories(categories: JsonField) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = apply { - body.categoriesOfCategorical(categorical) - } + fun categoriesOfCategorical(categorical: List) = + apply { + body.categoriesOfCategorical(categorical) + } /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } + fun categories(weighted: Categories.Weighted) = + apply { + body.categories(weighted) + } /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } + fun categoriesOfMinimum(minimum: List) = + apply { + body.categoriesOfMinimum(minimum) + } /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } + fun categories(nullableVariant: Categories.NullableVariant) = + apply { + body.categories(nullableVariant) + } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + fun config(config: ProjectScoreConfig?) = + apply { + body.config(config) + } fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { body.config(config) } + fun config(config: JsonField) = + apply { + body.config(config) + } /** Textual description of the project score */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project score */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreReplaceParams = ProjectScoreReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ScoreType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -586,9 +689,11 @@ private constructor( * An enum containing [ScoreType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ScoreType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -599,17 +704,18 @@ private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown value. + * An enum member indicating that [ScoreType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -625,11 +731,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -645,23 +751,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -672,13 +775,13 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( + class Categories private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { /** For categorical-type project scores, the list of all categories */ @@ -714,48 +817,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = apply { - if (validated) { - return@apply - } + fun validate(): Categories = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) {} + override fun visitMinimum(minimum: List) { + + } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -774,22 +878,23 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = - Categories(categorical = categorical) + fun ofCategorical(categorical: List) = Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic + fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic + fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of type [T]. + * An interface that defines how to map each variant of [Categories] to a value of + * type [T]. */ interface Visitor { @@ -807,70 +912,59 @@ private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [Categories] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Weighted @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -879,20 +973,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Weighted = apply { - if (validated) { - return@apply - } + fun validate(): Weighted = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -901,41 +997,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = + apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -948,11 +1049,9 @@ private constructor( } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -961,20 +1060,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -983,41 +1084,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1031,15 +1137,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 9521a052..8370d2d3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a project_score object by its id */ -class ProjectScoreRetrieveParams -private constructor( +class ProjectScoreRetrieveParams private constructor( private val projectScoreId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ProjectScore id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreRetrieveParams]. * * The following fields are required: + * * ```java * .projectScoreId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreRetrieveParams: ProjectScoreRetrieveParams) = apply { - projectScoreId = projectScoreRetrieveParams.projectScoreId - additionalHeaders = projectScoreRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreRetrieveParams: ProjectScoreRetrieveParams) = + apply { + projectScoreId = projectScoreRetrieveParams.projectScoreId + additionalHeaders = projectScoreRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreRetrieveParams.additionalQueryParams.toBuilder() + } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun projectScoreId(projectScoreId: String) = + apply { + this.projectScoreId = projectScoreId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( - checkRequired("projectScoreId", projectScoreId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectScoreId", projectScoreId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreRetrieveParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreRetrieveParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt index 4784736c..2dd1c1c2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt @@ -34,16 +34,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class ProjectScoreUpdateParams -private constructor( +class ProjectScoreUpdateParams private constructor( private val projectScoreId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ProjectScore id */ @@ -83,60 +83,48 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } - /** A project score is a user-configured score, which can be manually-labeled through the UI */ + /** + * A project score is a user-configured score, which can be manually-labeled + * through the UI + */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("categories") - @ExcludeMissing - private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - private val config: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("score_type") - @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = - Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) - fun config(): Optional = - Optional.ofNullable(config.getNullable("config")) + fun config(): Optional = Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The type of the configured score */ - fun scoreType(): Optional = - Optional.ofNullable(scoreType.getNullable("score_type")) + fun scoreType(): Optional = Optional.ofNullable(scoreType.getNullable("score_type")) /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @@ -153,7 +141,9 @@ private constructor( fun _description(): JsonField = description /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The type of the configured score */ @JsonProperty("score_type") @@ -166,25 +156,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - description() - name() - scoreType() - validated = true - } + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + name() + scoreType() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -198,44 +190,45 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - categories = body.categories - config = body.config - description = body.description - name = body.name - scoreType = body.scoreType - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + categories = body.categories + config = body.config + description = body.description + name = body.name + scoreType = body.scoreType + additionalProperties = body.additionalProperties.toMutableMap() + } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { - this.categories = categories - } + fun categories(categories: JsonField) = + apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = - categories(Categories.ofWeighted(weighted)) + fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = - categories(Categories.ofMinimum(minimum)) + fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { this.config = config } + fun config(config: JsonField) = + apply { + this.config = config + } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -244,9 +237,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the project score */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -255,7 +249,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the project score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The type of the configured score */ fun scoreType(scoreType: ScoreType?) = scoreType(JsonField.ofNullable(scoreType)) @@ -264,44 +261,54 @@ private constructor( fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = + apply { + this.scoreType = scoreType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - categories, - config, - description, - name, - scoreType, - additionalProperties.toImmutable(), + categories, + config, + description, + name, + scoreType, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -310,8 +317,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" + override fun toString() = "Body{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -319,14 +325,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreUpdateParams]. * * The following fields are required: + * * ```java * .projectScoreId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreUpdateParams]. */ @@ -339,207 +348,285 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreUpdateParams: ProjectScoreUpdateParams) = apply { - projectScoreId = projectScoreUpdateParams.projectScoreId - body = projectScoreUpdateParams.body.toBuilder() - additionalHeaders = projectScoreUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreUpdateParams: ProjectScoreUpdateParams) = + apply { + projectScoreId = projectScoreUpdateParams.projectScoreId + body = projectScoreUpdateParams.body.toBuilder() + additionalHeaders = projectScoreUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreUpdateParams.additionalQueryParams.toBuilder() + } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun projectScoreId(projectScoreId: String) = + apply { + this.projectScoreId = projectScoreId + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { body.categories(categories) } + fun categories(categories: Categories) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { body.categories(categories) } + fun categories(categories: JsonField) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = apply { - body.categoriesOfCategorical(categorical) - } + fun categoriesOfCategorical(categorical: List) = + apply { + body.categoriesOfCategorical(categorical) + } /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } + fun categories(weighted: Categories.Weighted) = + apply { + body.categories(weighted) + } /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } + fun categoriesOfMinimum(minimum: List) = + apply { + body.categoriesOfMinimum(minimum) + } /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } + fun categories(nullableVariant: Categories.NullableVariant) = + apply { + body.categories(nullableVariant) + } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + fun config(config: ProjectScoreConfig?) = + apply { + body.config(config) + } fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { body.config(config) } + fun config(config: JsonField) = + apply { + body.config(config) + } /** Textual description of the project score */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project score */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the project score */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the project score */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the project score */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType?) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: ScoreType?) = + apply { + body.scoreType(scoreType) + } /** The type of the configured score */ fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) /** The type of the configured score */ - fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } + fun scoreType(scoreType: JsonField) = + apply { + body.scoreType(scoreType) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreUpdateParams = ProjectScoreUpdateParams( - checkRequired("projectScoreId", projectScoreId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectScoreId", projectScoreId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( + class Categories private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { /** For categorical-type project scores, the list of all categories */ @@ -575,48 +662,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = apply { - if (validated) { - return@apply - } + fun validate(): Categories = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) {} + override fun visitMinimum(minimum: List) { + + } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -635,22 +723,23 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = - Categories(categorical = categorical) + fun ofCategorical(categorical: List) = Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic + fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic + fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of type [T]. + * An interface that defines how to map each variant of [Categories] to a value of + * type [T]. */ interface Visitor { @@ -668,70 +757,59 @@ private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [Categories] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Weighted @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -740,20 +818,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Weighted = apply { - if (validated) { - return@apply - } + fun validate(): Weighted = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -762,41 +842,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = + apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -809,11 +894,9 @@ private constructor( } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -822,20 +905,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -844,41 +929,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -892,17 +982,21 @@ private constructor( } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ScoreType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -935,9 +1029,11 @@ private constructor( * An enum containing [ScoreType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ScoreType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -948,17 +1044,18 @@ private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown value. + * An enum member indicating that [ScoreType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -974,11 +1071,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -994,23 +1091,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1019,15 +1113,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index 9c9bfe47..d786a3cf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -18,18 +18,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ProjectSettings -@JsonCreator -private constructor( - @JsonProperty("comparison_key") - @ExcludeMissing - private val comparisonKey: JsonField = JsonMissing.of(), +class ProjectSettings @JsonCreator private constructor( + @JsonProperty("comparison_key") @ExcludeMissing private val comparisonKey: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(): Optional = - Optional.ofNullable(comparisonKey.getNullable("comparison_key")) + fun comparisonKey(): Optional = Optional.ofNullable(comparisonKey.getNullable("comparison_key")) /** The key used to join two experiments (defaults to `input`). */ @JsonProperty("comparison_key") @@ -42,21 +38,23 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectSettings = apply { - if (validated) { - return@apply - } + fun validate(): ProjectSettings = + apply { + if (validated) { + return@apply + } - comparisonKey() - validated = true - } + comparisonKey() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ProjectSettings]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectSettings]. */ @@ -66,53 +64,62 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectSettings: ProjectSettings) = apply { - comparisonKey = projectSettings.comparisonKey - additionalProperties = projectSettings.additionalProperties.toMutableMap() - } + internal fun from(projectSettings: ProjectSettings) = + apply { + comparisonKey = projectSettings.comparisonKey + additionalProperties = projectSettings.additionalProperties.toMutableMap() + } /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: String?) = - comparisonKey(JsonField.ofNullable(comparisonKey)) + fun comparisonKey(comparisonKey: String?) = comparisonKey(JsonField.ofNullable(comparisonKey)) /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: Optional) = - comparisonKey(comparisonKey.getOrNull()) + fun comparisonKey(comparisonKey: Optional) = comparisonKey(comparisonKey.getOrNull()) /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: JsonField) = apply { - this.comparisonKey = comparisonKey - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun comparisonKey(comparisonKey: JsonField) = + apply { + this.comparisonKey = comparisonKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectSettings = - ProjectSettings(comparisonKey, additionalProperties.toImmutable()) + ProjectSettings( + comparisonKey, additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectSettings && comparisonKey == other.comparisonKey && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSettings && comparisonKey == other.comparisonKey && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -121,6 +128,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 69a309f6..f2246bf9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -20,29 +20,20 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * A project tag is a user-configured tag for tracking and filtering your experiments, logs, and - * other data + * A project tag is a user-configured tag for tracking and filtering your + * experiments, logs, and other data */ @NoAutoDetect -class ProjectTag -@JsonCreator -private constructor( +class ProjectTag @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the project tag */ @@ -63,28 +54,41 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the project tag */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Unique identifier for the project tag */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + @JsonProperty("color") + @ExcludeMissing + fun _color(): JsonField = color /** Date of project tag creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Textual description of the project tag */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing @@ -92,21 +96,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectTag = apply { - if (validated) { - return@apply + fun validate(): ProjectTag = + apply { + if (validated) { + return@apply + } + + id() + name() + projectId() + userId() + color() + created() + description() + validated = true } - id() - name() - projectId() - userId() - color() - created() - description() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -115,6 +120,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectTag]. * * The following fields are required: + * * ```java * .id() * .name() @@ -122,7 +128,8 @@ private constructor( * .userId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTag]. */ @@ -138,38 +145,51 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectTag: ProjectTag) = apply { - id = projectTag.id - name = projectTag.name - projectId = projectTag.projectId - userId = projectTag.userId - color = projectTag.color - created = projectTag.created - description = projectTag.description - additionalProperties = projectTag.additionalProperties.toMutableMap() - } + internal fun from(projectTag: ProjectTag) = + apply { + id = projectTag.id + name = projectTag.name + projectId = projectTag.projectId + userId = projectTag.userId + color = projectTag.color + created = projectTag.created + description = projectTag.description + additionalProperties = projectTag.additionalProperties.toMutableMap() + } /** Unique identifier for the project tag */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project tag */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project tag */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } fun userId(userId: String) = userId(JsonField.of(userId)) - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -178,7 +198,10 @@ private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { this.color = color } + fun color(color: JsonField) = + apply { + this.color = color + } /** Date of project tag creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -187,7 +210,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of project tag creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -196,46 +222,64 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { this.description = description } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun description(description: JsonField) = + apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectTag = ProjectTag( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("userId", userId), - color, - created, - description, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "userId", userId + ), + color, + created, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTag && id == other.id && name == other.name && projectId == other.projectId && userId == other.userId && color == other.color && created == other.created && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTag && id == other.id && name == other.name && projectId == other.projectId && userId == other.userId && color == other.color && created == other.created && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -244,6 +288,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectTag{id=$id, name=$name, projectId=$projectId, userId=$userId, color=$color, created=$created, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectTag{id=$id, name=$name, projectId=$projectId, userId=$userId, color=$color, created=$created, description=$description, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 1944b66e..fd9204c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new project_tag. If there is an existing project_tag in the project with the same name - * as the one specified in the request, will return the existing project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project + * with the same name as the one specified in the request, will return the existing + * project_tag unmodified */ -class ProjectTagCreateParams -private constructor( +class ProjectTagCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project tag */ @@ -62,30 +63,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project tag */ @@ -98,17 +90,22 @@ private constructor( fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + @JsonProperty("color") + @ExcludeMissing + fun _color(): JsonField = color /** Textual description of the project tag */ @JsonProperty("description") @@ -121,18 +118,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + color() + description() + validated = true } - name() - projectId() - color() - description() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -141,12 +139,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -159,25 +159,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - color = body.color - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + color = body.color + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project tag */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -186,7 +193,10 @@ private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { this.color = color } + fun color(color: JsonField) = + apply { + this.color = color + } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -195,45 +205,57 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { - this.description = description - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun description(description: JsonField) = + apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - color, - description, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + color, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -242,8 +264,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -251,15 +272,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagCreateParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagCreateParams]. */ @@ -271,177 +295,235 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagCreateParams: ProjectTagCreateParams) = apply { - body = projectTagCreateParams.body.toBuilder() - additionalHeaders = projectTagCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagCreateParams: ProjectTagCreateParams) = + apply { + body = projectTagCreateParams.body.toBuilder() + additionalHeaders = projectTagCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagCreateParams.additionalQueryParams.toBuilder() + } /** Name of the project tag */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project tag */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Color of the tag for the UI */ - fun color(color: String?) = apply { body.color(color) } + fun color(color: String?) = + apply { + body.color(color) + } /** Color of the tag for the UI */ fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { body.color(color) } + fun color(color: JsonField) = + apply { + body.color(color) + } /** Textual description of the project tag */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project tag */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagCreateParams = ProjectTagCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 1f3d8f1c..bcdd7f60 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a project_tag object by its id */ -class ProjectTagDeleteParams -private constructor( +class ProjectTagDeleteParams private constructor( private val projectTagId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** ProjectTag id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagDeleteParams]. * * The following fields are required: + * * ```java * .projectTagId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectTagDeleteParams: ProjectTagDeleteParams) = apply { - projectTagId = projectTagDeleteParams.projectTagId - additionalHeaders = projectTagDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectTagDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(projectTagDeleteParams: ProjectTagDeleteParams) = + apply { + projectTagId = projectTagDeleteParams.projectTagId + additionalHeaders = projectTagDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectTagDeleteParams.additionalBodyProperties.toMutableMap() + } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun projectTagId(projectTagId: String) = + apply { + this.projectTagId = projectTagId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( - checkRequired("projectTagId", projectTagId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "projectTagId", projectTagId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagDeleteParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagDeleteParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index 3fdf0ee1..6f5762aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.ProjectTagService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ -class ProjectTagListPage -private constructor( +class ProjectTagListPage private constructor( private val projectTagsService: ProjectTagService, private val params: ProjectTagListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagListPage && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectTagListPage && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ - override fun toString() = - "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" + override fun toString() = "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectTagListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectTagListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectTagsService.list(it) } + return getNextPageParams().map { projectTagsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectTagsService: ProjectTagService, - params: ProjectTagListParams, - response: Response, - ) = ProjectTagListPage(projectTagsService, params, response) + fun of(projectTagsService: ProjectTagService, params: ProjectTagListParams, response: Response) = + ProjectTagListPage( + projectTagsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ProjectTagListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectTagListPage) : Iterable { + class AutoPager( + private val firstPage: ProjectTagListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 885b7cbe..12379625 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.ProjectTagServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ -class ProjectTagListPageAsync -private constructor( +class ProjectTagListPageAsync private constructor( private val projectTagsService: ProjectTagServiceAsync, private val params: ProjectTagListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagListPageAsync && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectTagListPageAsync && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ - override fun toString() = - "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" + override fun toString() = "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectTagListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectTagListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { projectTagsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + projectTagsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectTagsService: ProjectTagServiceAsync, - params: ProjectTagListParams, - response: Response, - ) = ProjectTagListPageAsync(projectTagsService, params, response) + fun of(projectTagsService: ProjectTagServiceAsync, params: ProjectTagListParams, response: Response) = + ProjectTagListPageAsync( + projectTagsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -151,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectTagListPageAsync) { + class AutoPager( + private val firstPage: ProjectTagListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (ProjectTag) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (ProjectTag) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 431a8583..44d39849 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ -class ProjectTagListParams -private constructor( +class ProjectTagListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -38,20 +37,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -73,9 +73,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -86,27 +86,64 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.projectTagName?.let { queryParams.put("project_tag_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.projectTagName?.let { + queryParams.put( + "project_tag_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ProjectTagListParams = builder().build() + @JvmStatic + fun none(): ProjectTagListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [ProjectTagListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ProjectTagListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagListParams]. */ @@ -125,63 +162,73 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagListParams: ProjectTagListParams) = apply { - endingBefore = projectTagListParams.endingBefore - ids = projectTagListParams.ids - limit = projectTagListParams.limit - orgName = projectTagListParams.orgName - projectId = projectTagListParams.projectId - projectName = projectTagListParams.projectName - projectTagName = projectTagListParams.projectTagName - startingAfter = projectTagListParams.startingAfter - additionalHeaders = projectTagListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagListParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagListParams: ProjectTagListParams) = + apply { + endingBefore = projectTagListParams.endingBefore + ids = projectTagListParams.ids + limit = projectTagListParams.limit + orgName = projectTagListParams.orgName + projectId = projectTagListParams.projectId + projectName = projectTagListParams.projectName + projectTagName = projectTagListParams.projectTagName + startingAfter = projectTagListParams.startingAfter + additionalHeaders = projectTagListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -190,173 +237,212 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_tag to search for */ - fun projectTagName(projectTagName: String?) = apply { this.projectTagName = projectTagName } + fun projectTagName(projectTagName: String?) = + apply { + this.projectTagName = projectTagName + } /** Name of the project_tag to search for */ - fun projectTagName(projectTagName: Optional) = - projectTagName(projectTagName.getOrNull()) + fun projectTagName(projectTagName: Optional) = projectTagName(projectTagName.getOrNull()) /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagListParams = ProjectTagListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectTagName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectTagName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -374,19 +460,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -401,12 +487,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -416,60 +507,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectTagName == other.projectTagName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectTagName == other.projectTagName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index ab167ca1..f9bf8d6e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -22,15 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will replace the existing project_tag with the provided - * fields + * Create or replace project_tag. If there is an existing project_tag in the + * project with the same name as the one specified in the request, will replace the + * existing project_tag with the provided fields */ -class ProjectTagReplaceParams -private constructor( +class ProjectTagReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project tag */ @@ -63,30 +63,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project tag */ @@ -99,17 +90,22 @@ private constructor( fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + @JsonProperty("color") + @ExcludeMissing + fun _color(): JsonField = color /** Textual description of the project tag */ @JsonProperty("description") @@ -122,18 +118,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + color() + description() + validated = true } - name() - projectId() - color() - description() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -142,12 +139,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -160,25 +159,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - color = body.color - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + color = body.color + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project tag */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -187,7 +193,10 @@ private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { this.color = color } + fun color(color: JsonField) = + apply { + this.color = color + } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -196,45 +205,57 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { - this.description = description - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun description(description: JsonField) = + apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - color, - description, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + color, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -243,8 +264,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -252,15 +272,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagReplaceParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagReplaceParams]. */ @@ -272,177 +295,235 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagReplaceParams: ProjectTagReplaceParams) = apply { - body = projectTagReplaceParams.body.toBuilder() - additionalHeaders = projectTagReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagReplaceParams: ProjectTagReplaceParams) = + apply { + body = projectTagReplaceParams.body.toBuilder() + additionalHeaders = projectTagReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the project tag */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project tag */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Color of the tag for the UI */ - fun color(color: String?) = apply { body.color(color) } + fun color(color: String?) = + apply { + body.color(color) + } /** Color of the tag for the UI */ fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { body.color(color) } + fun color(color: JsonField) = + apply { + body.color(color) + } /** Textual description of the project tag */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project tag */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagReplaceParams = ProjectTagReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 90bd6349..5a5b92f3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a project_tag object by its id */ -class ProjectTagRetrieveParams -private constructor( +class ProjectTagRetrieveParams private constructor( private val projectTagId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ProjectTag id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagRetrieveParams]. * * The following fields are required: + * * ```java * .projectTagId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagRetrieveParams: ProjectTagRetrieveParams) = apply { - projectTagId = projectTagRetrieveParams.projectTagId - additionalHeaders = projectTagRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagRetrieveParams: ProjectTagRetrieveParams) = + apply { + projectTagId = projectTagRetrieveParams.projectTagId + additionalHeaders = projectTagRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagRetrieveParams.additionalQueryParams.toBuilder() + } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun projectTagId(projectTagId: String) = + apply { + this.projectTagId = projectTagId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( - checkRequired("projectTagId", projectTagId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectTagId", projectTagId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagRetrieveParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagRetrieveParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 8a93825d..1e44d79d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class ProjectTagUpdateParams -private constructor( +class ProjectTagUpdateParams private constructor( private val projectTagId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ProjectTag id */ @@ -61,48 +61,42 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Color of the tag for the UI */ fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project tag */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + @JsonProperty("color") + @ExcludeMissing + fun _color(): JsonField = color /** Textual description of the project tag */ @JsonProperty("description") @@ -110,7 +104,9 @@ private constructor( fun _description(): JsonField = description /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -118,23 +114,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + color() + description() + name() + validated = true } - color() - description() - name() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -146,12 +144,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - color = body.color - description = body.description - name = body.name - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + color = body.color + description = body.description + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -160,7 +159,10 @@ private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { this.color = color } + fun color(color: JsonField) = + apply { + this.color = color + } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -169,9 +171,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the project tag */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -180,36 +183,52 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the project tag */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = Body(color, description, name, additionalProperties.toImmutable()) + fun name(name: JsonField) = + apply { + this.name = name + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = + Body( + color, + description, + name, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && color == other.color && description == other.description && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && color == other.color && description == other.description && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -218,8 +237,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Body{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -227,14 +245,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagUpdateParams]. * * The following fields are required: + * * ```java * .projectTagId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagUpdateParams]. */ @@ -247,179 +268,236 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagUpdateParams: ProjectTagUpdateParams) = apply { - projectTagId = projectTagUpdateParams.projectTagId - body = projectTagUpdateParams.body.toBuilder() - additionalHeaders = projectTagUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagUpdateParams: ProjectTagUpdateParams) = + apply { + projectTagId = projectTagUpdateParams.projectTagId + body = projectTagUpdateParams.body.toBuilder() + additionalHeaders = projectTagUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagUpdateParams.additionalQueryParams.toBuilder() + } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun projectTagId(projectTagId: String) = + apply { + this.projectTagId = projectTagId + } /** Color of the tag for the UI */ - fun color(color: String?) = apply { body.color(color) } + fun color(color: String?) = + apply { + body.color(color) + } /** Color of the tag for the UI */ fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { body.color(color) } + fun color(color: JsonField) = + apply { + body.color(color) + } /** Textual description of the project tag */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project tag */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the project tag */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the project tag */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the project tag */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagUpdateParams = ProjectTagUpdateParams( - checkRequired("projectTagId", projectTagId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectTagId", projectTagId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagUpdateParams{projectTagId=$projectTagId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagUpdateParams{projectTagId=$projectTagId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index f47cf5da..7fefab19 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a project object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a project object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class ProjectUpdateParams -private constructor( +class ProjectUpdateParams private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -41,8 +41,8 @@ private constructor( fun name(): Optional = body.name() /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun settings(): Optional = body.settings() @@ -50,8 +50,8 @@ private constructor( fun _name(): JsonField = body._name() /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun _settings(): JsonField = body._settings() @@ -61,49 +61,45 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("settings") - @ExcludeMissing - private val settings: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("settings") @ExcludeMissing private val settings: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ - fun settings(): Optional = - Optional.ofNullable(settings.getNullable("settings")) + fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ @JsonProperty("settings") @ExcludeMissing @@ -115,22 +111,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - settings().ifPresent { it.validate() } - validated = true - } + name() + settings().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -141,11 +139,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - settings = body.settings - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + settings = body.settings + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -154,54 +153,72 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the project */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun settings(settings: Optional) = settings(settings.getOrNull()) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ - fun settings(settings: JsonField) = apply { this.settings = settings } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = Body(name, settings, additionalProperties.toImmutable()) + fun settings(settings: JsonField) = + apply { + this.settings = settings + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = + Body( + name, + settings, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -210,8 +227,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, settings=$settings, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, settings=$settings, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -222,11 +238,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectUpdateParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectUpdateParams]. */ @@ -239,179 +257,230 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectUpdateParams: ProjectUpdateParams) = apply { - projectId = projectUpdateParams.projectId - body = projectUpdateParams.body.toBuilder() - additionalHeaders = projectUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectUpdateParams: ProjectUpdateParams) = + apply { + projectId = projectUpdateParams.projectId + body = projectUpdateParams.body.toBuilder() + additionalHeaders = projectUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectUpdateParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** Name of the project */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the project */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the project */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ - fun settings(settings: ProjectSettings?) = apply { body.settings(settings) } + fun settings(settings: ProjectSettings?) = + apply { + body.settings(settings) + } /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun settings(settings: Optional) = settings(settings.getOrNull()) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ - fun settings(settings: JsonField) = apply { body.settings(settings) } + fun settings(settings: JsonField) = + apply { + body.settings(settings) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectUpdateParams = ProjectUpdateParams( - checkRequired("projectId", projectId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectUpdateParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectUpdateParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 5e093784..13fcc876 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -23,48 +23,32 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Prompt -@JsonCreator -private constructor( +class Prompt @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -87,59 +71,77 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) /** User-controlled metadata about the prompt */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId + @JsonProperty("log_id") + @ExcludeMissing + fun _logId(): JsonField = logId /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description @JsonProperty("function_type") @ExcludeMissing fun _functionType(): JsonField = functionType /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -147,7 +149,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -155,26 +159,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - id() - _xactId() - logId() - name() - orgId() - projectId() - slug() - created() - description() - functionType() - metadata().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + id() + _xactId() + logId() + name() + orgId() + projectId() + slug() + created() + description() + functionType() + metadata().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -184,6 +189,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -194,7 +200,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -216,72 +223,96 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - id = prompt.id - _xactId = prompt._xactId - logId = prompt.logId - name = prompt.name - orgId = prompt.orgId - projectId = prompt.projectId - slug = prompt.slug - created = prompt.created - description = prompt.description - functionType = prompt.functionType - metadata = prompt.metadata - promptData = prompt.promptData - tags = prompt.tags.map { it.toMutableList() } - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + id = prompt.id + _xactId = prompt._xactId + logId = prompt.logId + name = prompt.name + orgId = prompt.orgId + projectId = prompt.projectId + slug = prompt.slug + created = prompt.created + description = prompt.description + functionType = prompt.functionType + metadata = prompt.metadata + promptData = prompt.promptData + tags = prompt.tags.map { it.toMutableList() } + additionalProperties = prompt.additionalProperties.toMutableMap() + } /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: JsonField) = apply { this.logId = logId } + fun logId(logId: JsonField) = + apply { + this.logId = logId + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Date of prompt creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -290,7 +321,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of prompt creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -299,17 +333,19 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -318,7 +354,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the prompt */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -327,7 +366,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -336,65 +378,94 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = Prompt( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("logId", logId), - checkRequired("name", name), - checkRequired("orgId", orgId), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - created, - description, - functionType, - metadata, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "logId", logId + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + created, + description, + functionType, + metadata, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** A literal 'p' which identifies the object as a project prompt */ - class LogId @JsonCreator private constructor(private val value: JsonField) : Enum { + class LogId @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -405,16 +476,18 @@ private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - P + P, } /** * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LogId] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -424,11 +497,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -439,11 +512,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -454,23 +527,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -478,18 +548,21 @@ private constructor( override fun toString() = value.toString() } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -513,12 +586,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -527,17 +603,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -551,11 +628,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -569,23 +646,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -595,11 +669,9 @@ private constructor( /** User-controlled metadata about the prompt */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -608,20 +680,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -630,38 +704,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -674,11 +756,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && id == other.id && _xactId == other._xactId && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionType == other.functionType && metadata == other.metadata && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && id == other.id && _xactId == other._xactId && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionType == other.functionType && metadata == other.metadata && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -687,6 +769,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{id=$id, _xactId=$_xactId, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionType=$functionType, metadata=$metadata, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{id=$id, _xactId=$_xactId, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionType=$functionType, metadata=$metadata, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 3eee9b8f..0a6c199e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -25,14 +25,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the one - * specified in the request, will return the existing prompt unmodified + * Create a new prompt. If there is an existing prompt in the project with the same + * slug as the one specified in the request, will return the existing prompt + * unmodified */ -class PromptCreateParams -private constructor( +class PromptCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the prompt */ @@ -81,39 +82,24 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the prompt */ @@ -126,27 +112,30 @@ private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -163,7 +152,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -171,21 +162,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + slug() + description() + functionType() + promptData().ifPresent { it.validate() } + tags() + validated = true } - name() - projectId() - slug() - description() - functionType() - promptData().ifPresent { it.validate() } - tags() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -194,13 +186,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -216,34 +210,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionType = body.functionType - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionType = body.functionType + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -252,19 +256,19 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -273,9 +277,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -284,54 +289,70 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - description, - functionType, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + description, + functionType, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -340,8 +361,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -352,13 +372,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptCreateParams]. */ @@ -370,206 +392,286 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptCreateParams: PromptCreateParams) = apply { - body = promptCreateParams.body.toBuilder() - additionalHeaders = promptCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = promptCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(promptCreateParams: PromptCreateParams) = + apply { + body = promptCreateParams.body.toBuilder() + additionalHeaders = promptCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = promptCreateParams.additionalQueryParams.toBuilder() + } /** Name of the prompt */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { body.slug(slug) } + fun slug(slug: String) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + fun functionType(functionType: FunctionType?) = + apply { + body.functionType(functionType) + } - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = + apply { + body.functionType(functionType) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptCreateParams = PromptCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -593,12 +695,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -607,17 +712,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -631,11 +737,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -649,23 +755,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -674,15 +777,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index c9faaa96..7ab2daf4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -33,25 +33,14 @@ import kotlin.jvm.optionals.getOrNull /** The prompt, model, and its parameters */ @NoAutoDetect -class PromptData -@JsonCreator -private constructor( - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("parser") - @ExcludeMissing - private val parser: JsonField = JsonMissing.of(), - @JsonProperty("prompt") - @ExcludeMissing - private val prompt: JsonField = JsonMissing.of(), - @JsonProperty("tool_functions") - @ExcludeMissing - private val toolFunctions: JsonField> = JsonMissing.of(), +class PromptData @JsonCreator private constructor( + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("parser") @ExcludeMissing private val parser: JsonField = JsonMissing.of(), + @JsonProperty("prompt") @ExcludeMissing private val prompt: JsonField = JsonMissing.of(), + @JsonProperty("tool_functions") @ExcludeMissing private val toolFunctions: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -62,16 +51,23 @@ private constructor( fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - fun toolFunctions(): Optional> = - Optional.ofNullable(toolFunctions.getNullable("tool_functions")) + fun toolFunctions(): Optional> = Optional.ofNullable(toolFunctions.getNullable("tool_functions")) - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin - @JsonProperty("parser") @ExcludeMissing fun _parser(): JsonField = parser + @JsonProperty("parser") + @ExcludeMissing + fun _parser(): JsonField = parser - @JsonProperty("prompt") @ExcludeMissing fun _prompt(): JsonField = prompt + @JsonProperty("prompt") + @ExcludeMissing + fun _prompt(): JsonField = prompt @JsonProperty("tool_functions") @ExcludeMissing @@ -83,25 +79,27 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptData = apply { - if (validated) { - return@apply - } + fun validate(): PromptData = + apply { + if (validated) { + return@apply + } - options().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - parser().ifPresent { it.validate() } - prompt().ifPresent { it.validate() } - toolFunctions().ifPresent { it.forEach { it.validate() } } - validated = true - } + options().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + parser().ifPresent { it.validate() } + prompt().ifPresent { it.validate() } + toolFunctions().ifPresent { it.forEach { it.validate() } } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [PromptData]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptData]. */ @@ -115,124 +113,135 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptData: PromptData) = apply { - options = promptData.options - origin = promptData.origin - parser = promptData.parser - prompt = promptData.prompt - toolFunctions = promptData.toolFunctions.map { it.toMutableList() } - additionalProperties = promptData.additionalProperties.toMutableMap() - } + internal fun from(promptData: PromptData) = + apply { + options = promptData.options + origin = promptData.origin + parser = promptData.parser + prompt = promptData.prompt + toolFunctions = promptData.toolFunctions.map { it.toMutableList() } + additionalProperties = promptData.additionalProperties.toMutableMap() + } fun options(options: PromptOptions?) = options(JsonField.ofNullable(options)) fun options(options: Optional) = options(options.getOrNull()) - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } fun parser(parser: Parser?) = parser(JsonField.ofNullable(parser)) fun parser(parser: Optional) = parser(parser.getOrNull()) - fun parser(parser: JsonField) = apply { this.parser = parser } + fun parser(parser: JsonField) = + apply { + this.parser = parser + } fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) - fun prompt(prompt: JsonField) = apply { this.prompt = prompt } + fun prompt(prompt: JsonField) = + apply { + this.prompt = prompt + } fun prompt(completion: Prompt.Completion) = prompt(Prompt.ofCompletion(completion)) fun prompt(chat: Prompt.Chat) = prompt(Prompt.ofChat(chat)) - fun prompt(nullableVariant: Prompt.NullableVariant) = - prompt(Prompt.ofNullableVariant(nullableVariant)) + fun prompt(nullableVariant: Prompt.NullableVariant) = prompt(Prompt.ofNullableVariant(nullableVariant)) - fun toolFunctions(toolFunctions: List?) = - toolFunctions(JsonField.ofNullable(toolFunctions)) + fun toolFunctions(toolFunctions: List?) = toolFunctions(JsonField.ofNullable(toolFunctions)) - fun toolFunctions(toolFunctions: Optional>) = - toolFunctions(toolFunctions.getOrNull()) + fun toolFunctions(toolFunctions: Optional>) = toolFunctions(toolFunctions.getOrNull()) - fun toolFunctions(toolFunctions: JsonField>) = apply { - this.toolFunctions = toolFunctions.map { it.toMutableList() } - } + fun toolFunctions(toolFunctions: JsonField>) = + apply { + this.toolFunctions = toolFunctions.map { it.toMutableList() } + } - fun addToolFunction(toolFunction: ToolFunction) = apply { - toolFunctions = - (toolFunctions ?: JsonField.of(mutableListOf())).also { + fun addToolFunction(toolFunction: ToolFunction) = + apply { + toolFunctions = (toolFunctions ?: JsonField.of(mutableListOf())).also { checkKnown("toolFunctions", it).add(toolFunction) } - } + } - fun addToolFunction(function: ToolFunction.Function) = - addToolFunction(ToolFunction.ofFunction(function)) + fun addToolFunction(function: ToolFunction.Function) = addToolFunction(ToolFunction.ofFunction(function)) - fun addToolFunction(global: ToolFunction.Global) = - addToolFunction(ToolFunction.ofGlobal(global)) + fun addToolFunction(global: ToolFunction.Global) = addToolFunction(ToolFunction.ofGlobal(global)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptData = PromptData( - options, - origin, - parser, - prompt, - (toolFunctions ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + options, + origin, + parser, + prompt, + (toolFunctions ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_id") - @ExcludeMissing - private val promptId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_version") - @ExcludeMissing - private val promptVersion: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Origin @JsonCreator private constructor( + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_id") @ExcludeMissing private val promptId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_version") @ExcludeMissing private val promptVersion: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) fun promptId(): Optional = Optional.ofNullable(promptId.getNullable("prompt_id")) - fun promptVersion(): Optional = - Optional.ofNullable(promptVersion.getNullable("prompt_version")) + fun promptVersion(): Optional = Optional.ofNullable(promptVersion.getNullable("prompt_version")) - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId - @JsonProperty("prompt_id") @ExcludeMissing fun _promptId(): JsonField = promptId + @JsonProperty("prompt_id") + @ExcludeMissing + fun _promptId(): JsonField = promptId @JsonProperty("prompt_version") @ExcludeMissing @@ -244,23 +253,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - projectId() - promptId() - promptVersion() - validated = true - } + projectId() + promptId() + promptVersion() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Origin]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -272,56 +283,76 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - projectId = origin.projectId - promptId = origin.promptId - promptVersion = origin.promptVersion - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + projectId = origin.projectId + promptId = origin.promptId + promptVersion = origin.promptVersion + additionalProperties = origin.additionalProperties.toMutableMap() + } fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } fun promptId(promptId: String) = promptId(JsonField.of(promptId)) - fun promptId(promptId: JsonField) = apply { this.promptId = promptId } + fun promptId(promptId: JsonField) = + apply { + this.promptId = promptId + } fun promptVersion(promptVersion: String) = promptVersion(JsonField.of(promptVersion)) - fun promptVersion(promptVersion: JsonField) = apply { - this.promptVersion = promptVersion - } + fun promptVersion(promptVersion: JsonField) = + apply { + this.promptVersion = promptVersion + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = - Origin(projectId, promptId, promptVersion, additionalProperties.toImmutable()) + Origin( + projectId, + promptId, + promptVersion, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && projectId == other.projectId && promptId == other.promptId && promptVersion == other.promptVersion && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && projectId == other.projectId && promptId == other.promptId && promptVersion == other.promptVersion && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -330,23 +361,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{projectId=$projectId, promptId=$promptId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{projectId=$projectId, promptId=$promptId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Parser - @JsonCreator - private constructor( - @JsonProperty("choice_scores") - @ExcludeMissing - private val choiceScores: JsonField = JsonMissing.of(), + class Parser @JsonCreator private constructor( + @JsonProperty("choice_scores") @ExcludeMissing private val choiceScores: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("use_cot") - @ExcludeMissing - private val useCot: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("use_cot") @ExcludeMissing private val useCot: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun choiceScores(): ChoiceScores = choiceScores.getRequired("choice_scores") @@ -359,9 +383,13 @@ private constructor( @ExcludeMissing fun _choiceScores(): JsonField = choiceScores - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type - @JsonProperty("use_cot") @ExcludeMissing fun _useCot(): JsonField = useCot + @JsonProperty("use_cot") + @ExcludeMissing + fun _useCot(): JsonField = useCot @JsonAnyGetter @ExcludeMissing @@ -369,16 +397,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Parser = apply { - if (validated) { - return@apply - } + fun validate(): Parser = + apply { + if (validated) { + return@apply + } - choiceScores().validate() - type() - useCot() - validated = true - } + choiceScores().validate() + type() + useCot() + validated = true + } fun toBuilder() = Builder().from(this) @@ -388,13 +417,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Parser]. * * The following fields are required: + * * ```java * .choiceScores() * .type() * .useCot() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Parser]. */ @@ -406,61 +437,80 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(parser: Parser) = apply { - choiceScores = parser.choiceScores - type = parser.type - useCot = parser.useCot - additionalProperties = parser.additionalProperties.toMutableMap() - } + internal fun from(parser: Parser) = + apply { + choiceScores = parser.choiceScores + type = parser.type + useCot = parser.useCot + additionalProperties = parser.additionalProperties.toMutableMap() + } fun choiceScores(choiceScores: ChoiceScores) = choiceScores(JsonField.of(choiceScores)) - fun choiceScores(choiceScores: JsonField) = apply { - this.choiceScores = choiceScores - } + fun choiceScores(choiceScores: JsonField) = + apply { + this.choiceScores = choiceScores + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun useCot(useCot: Boolean) = useCot(JsonField.of(useCot)) - fun useCot(useCot: JsonField) = apply { this.useCot = useCot } + fun useCot(useCot: JsonField) = + apply { + this.useCot = useCot + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Parser = Parser( - checkRequired("choiceScores", choiceScores), - checkRequired("type", type), - checkRequired("useCot", useCot), - additionalProperties.toImmutable(), + checkRequired( + "choiceScores", choiceScores + ), + checkRequired( + "type", type + ), + checkRequired( + "useCot", useCot + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class ChoiceScores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class ChoiceScores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -469,20 +519,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ChoiceScores = apply { - if (validated) { - return@apply - } + fun validate(): ChoiceScores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ChoiceScores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ChoiceScores]. */ @@ -491,41 +543,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(choiceScores: ChoiceScores) = apply { - additionalProperties = choiceScores.additionalProperties.toMutableMap() - } + internal fun from(choiceScores: ChoiceScores) = + apply { + additionalProperties = choiceScores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChoiceScores = ChoiceScores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChoiceScores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChoiceScores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -537,17 +594,21 @@ private constructor( override fun toString() = "ChoiceScores{additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -558,16 +619,18 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - LLM_CLASSIFIER + LLM_CLASSIFIER, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -580,8 +643,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -596,7 +659,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -610,20 +673,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -632,11 +692,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Parser && choiceScores == other.choiceScores && type == other.type && useCot == other.useCot && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Parser && choiceScores == other.choiceScores && type == other.type && useCot == other.useCot && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -645,18 +705,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Parser{choiceScores=$choiceScores, type=$type, useCot=$useCot, additionalProperties=$additionalProperties}" + override fun toString() = "Parser{choiceScores=$choiceScores, type=$type, useCot=$useCot, additionalProperties=$additionalProperties}" } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt - private constructor( + class Prompt private constructor( private val completion: Completion? = null, private val chat: Chat? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { fun completion(): Optional = Optional.ofNullable(completion) @@ -680,45 +739,44 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - completion != null -> visitor.visitCompletion(completion) - chat != null -> visitor.visitChat(chat) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCompletion(completion: Completion) { - completion.validate() + completion.validate() } override fun visitChat(chat: Chat) { - chat.validate() + chat.validate() } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(completion, chat, nullableVariant) /* spotless:on */ @@ -734,16 +792,20 @@ private constructor( companion object { - @JvmStatic fun ofCompletion(completion: Completion) = Prompt(completion = completion) + @JvmStatic + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) + @JvmStatic + fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Prompt(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Prompt(nullableVariant = nullableVariant) } - /** An interface that defines how to map each variant of [Prompt] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Prompt] to a value of type + * [T]. + */ interface Visitor { fun visitCompletion(completion: Completion): T @@ -755,78 +817,69 @@ private constructor( /** * Maps an unknown variant of [Prompt] to a value of type [T]. * - * An instance of [Prompt] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Prompt] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } internal class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(completion = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(chat = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(nullableVariant = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } internal class Serializer : BaseSerializer(Prompt::class) { - override fun serialize( - value: Prompt, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.completion != null -> generator.writeObject(value.completion) - value.chat != null -> generator.writeObject(value.chat) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } @NoAutoDetect - class Completion - @JsonCreator - private constructor( - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Completion @JsonCreator private constructor( + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun content(): String = content.getRequired("content") fun type(): Type = type.getRequired("type") - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -834,15 +887,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Completion = apply { - if (validated) { - return@apply - } + fun validate(): Completion = + apply { + if (validated) { + return@apply + } - content() - type() - validated = true - } + content() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -852,12 +906,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Completion]. * * The following fields are required: + * * ```java * .content() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Completion]. */ @@ -868,52 +924,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(completion: Completion) = apply { - content = completion.content - type = completion.type - additionalProperties = completion.additionalProperties.toMutableMap() - } + internal fun from(completion: Completion) = + apply { + content = completion.content + type = completion.type + additionalProperties = completion.additionalProperties.toMutableMap() + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Completion = Completion( - checkRequired("content", content), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "content", content + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -923,7 +996,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -934,23 +1008,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - COMPLETION + COMPLETION, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { COMPLETION, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -974,7 +1048,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -989,19 +1063,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1010,11 +1081,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Completion && content == other.content && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Completion && content == other.content && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1023,25 +1094,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Completion{content=$content, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Completion{content=$content, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Chat - @JsonCreator - private constructor( - @JsonProperty("messages") - @ExcludeMissing - private val messages: JsonField> = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonProperty("tools") - @ExcludeMissing - private val tools: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Chat @JsonCreator private constructor( + @JsonProperty("messages") @ExcludeMissing private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("tools") @ExcludeMissing private val tools: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun messages(): List = messages.getRequired("messages") @@ -1054,9 +1116,13 @@ private constructor( @ExcludeMissing fun _messages(): JsonField> = messages - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type - @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField = tools + @JsonProperty("tools") + @ExcludeMissing + fun _tools(): JsonField = tools @JsonAnyGetter @ExcludeMissing @@ -1064,16 +1130,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Chat = apply { - if (validated) { - return@apply - } + fun validate(): Chat = + apply { + if (validated) { + return@apply + } - messages().forEach { it.validate() } - type() - tools() - validated = true - } + messages().forEach { it.validate() } + type() + tools() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1083,12 +1150,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Chat]. * * The following fields are required: + * * ```java * .messages() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Chat]. */ @@ -1100,84 +1169,96 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chat: Chat) = apply { - messages = chat.messages.map { it.toMutableList() } - type = chat.type - tools = chat.tools - additionalProperties = chat.additionalProperties.toMutableMap() - } + internal fun from(chat: Chat) = + apply { + messages = chat.messages.map { it.toMutableList() } + type = chat.type + tools = chat.tools + additionalProperties = chat.additionalProperties.toMutableMap() + } fun messages(messages: List) = messages(JsonField.of(messages)) - fun messages(messages: JsonField>) = apply { - this.messages = messages.map { it.toMutableList() } - } + fun messages(messages: JsonField>) = + apply { + this.messages = messages.map { it.toMutableList() } + } - fun addMessage(message: Message) = apply { - messages = - (messages ?: JsonField.of(mutableListOf())).also { + fun addMessage(message: Message) = + apply { + messages = (messages ?: JsonField.of(mutableListOf())).also { checkKnown("messages", it).add(message) } - } + } fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) - fun addMessage(assistant: Message.Assistant) = - addMessage(Message.ofAssistant(assistant)) + fun addMessage(assistant: Message.Assistant) = addMessage(Message.ofAssistant(assistant)) fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) - fun addMessage(function: Message.Function) = - addMessage(Message.ofFunction(function)) + fun addMessage(function: Message.Function) = addMessage(Message.ofFunction(function)) - fun addMessage(fallback: Message.Fallback) = - addMessage(Message.ofFallback(fallback)) + fun addMessage(fallback: Message.Fallback) = addMessage(Message.ofFallback(fallback)) fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun tools(tools: String) = tools(JsonField.of(tools)) - fun tools(tools: JsonField) = apply { this.tools = tools } + fun tools(tools: JsonField) = + apply { + this.tools = tools + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Chat = Chat( - checkRequired("messages", messages).map { it.toImmutable() }, - checkRequired("type", type), - tools, - additionalProperties.toImmutable(), + checkRequired( + "messages", messages + ).map { it.toImmutable() }, + checkRequired( + "type", type + ), + tools, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( + class Message private constructor( private val system: System? = null, private val user: User? = null, private val assistant: Assistant? = null, @@ -1185,6 +1266,7 @@ private constructor( private val function: Function? = null, private val fallback: Fallback? = null, private val _json: JsonValue? = null, + ) { fun system(): Optional = Optional.ofNullable(system) @@ -1226,60 +1308,59 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - system != null -> visitor.visitSystem(system) - user != null -> visitor.visitUser(user) - assistant != null -> visitor.visitAssistant(assistant) - tool != null -> visitor.visitTool(tool) - function != null -> visitor.visitFunction(function) - fallback != null -> visitor.visitFallback(fallback) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Message = apply { - if (validated) { - return@apply - } + fun validate(): Message = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitSystem(system: System) { - system.validate() + system.validate() } override fun visitUser(user: User) { - user.validate() + user.validate() } override fun visitAssistant(assistant: Assistant) { - assistant.validate() + assistant.validate() } override fun visitTool(tool: Tool) { - tool.validate() + tool.validate() } override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitFallback(fallback: Fallback) { - fallback.validate() + fallback.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ + return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ @@ -1298,23 +1379,28 @@ private constructor( companion object { - @JvmStatic fun ofSystem(system: System) = Message(system = system) + @JvmStatic + fun ofSystem(system: System) = Message(system = system) - @JvmStatic fun ofUser(user: User) = Message(user = user) + @JvmStatic + fun ofUser(user: User) = Message(user = user) @JvmStatic fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) + @JvmStatic + fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic fun ofFunction(function: Function) = Message(function = function) + @JvmStatic + fun ofFunction(function: Function) = Message(function = function) - @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) + @JvmStatic + fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } /** - * An interface that defines how to map each variant of [Message] to a value of type - * [T]. + * An interface that defines how to map each variant of [Message] to a value of + * type [T]. */ interface Visitor { @@ -1333,103 +1419,88 @@ private constructor( /** * Maps an unknown variant of [Message] to a value of type [T]. * - * An instance of [Message] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * An instance of [Message] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } internal class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(fallback = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } internal class Serializer : BaseSerializer(Message::class) { - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } @NoAutoDetect - class System - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class System @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1437,16 +1508,17 @@ private constructor( private var validated: Boolean = false - fun validate(): System = apply { - if (validated) { - return@apply - } + fun validate(): System = + apply { + if (validated) { + return@apply + } - role() - content() - name() - validated = true - } + role() + content() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1456,11 +1528,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [System]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [System]. */ @@ -1469,28 +1543,37 @@ private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(system: System) = apply { - role = system.role - content = system.content - name = system.name - additionalProperties = system.additionalProperties.toMutableMap() - } + internal fun from(system: System) = + apply { + role = system.role + content = system.content + name = system.name + additionalProperties = system.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1498,42 +1581,49 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): System = System( - checkRequired("role", role), - content, - name, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + name, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1547,25 +1637,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - SYSTEM + SYSTEM, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { SYSTEM, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1573,8 +1661,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1585,11 +1673,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1600,23 +1688,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1625,11 +1710,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1638,41 +1723,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class User - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + override fun toString() = "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class User @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1680,16 +1759,17 @@ private constructor( private var validated: Boolean = false - fun validate(): User = apply { - if (validated) { - return@apply - } + fun validate(): User = + apply { + if (validated) { + return@apply + } - role() - content().ifPresent { it.validate() } - name() - validated = true - } + role() + content().ifPresent { it.validate() } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1699,11 +1779,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [User]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [User]. */ @@ -1712,33 +1794,41 @@ private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(user: User) = apply { - role = user.role - content = user.content - name = user.name - additionalProperties = user.additionalProperties.toMutableMap() - } + internal fun from(user: User) = + apply { + role = user.role + content = user.content + name = user.name + additionalProperties = user.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: Content) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun content(text: String) = content(Content.ofText(text)) - fun contentOfArray(array: List) = - content(Content.ofArray(array)) + fun contentOfArray(array: List) = content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1746,42 +1836,49 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): User = User( - checkRequired("role", role), - content, - name, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + name, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1795,25 +1892,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - USER + USER, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { USER, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1821,8 +1916,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1833,11 +1928,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1848,23 +1943,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1874,17 +1966,16 @@ private constructor( @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( + class Content private constructor( private val text: String? = null, private val array: List? = null, private val _json: JsonValue? = null, + ) { fun text(): Optional = Optional.ofNullable(text) - fun array(): Optional> = - Optional.ofNullable(array) + fun array(): Optional> = Optional.ofNullable(array) fun isText(): Boolean = text != null @@ -1897,40 +1988,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Content = apply { - if (validated) { - return@apply - } + fun validate(): Content = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitText(text: String) {} + accept(object : Visitor { + override fun visitText(text: String) { - override fun visitArray( - array: List - ) { - array.forEach { it.validate() } } - } - ) - validated = true - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun visitArray(array: List) { + array.forEach { it.validate() } + } + }) + validated = true } - return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, array) /* spotless:on */ @@ -1945,16 +2035,16 @@ private constructor( companion object { - @JvmStatic fun ofText(text: String) = Content(text = text) + @JvmStatic + fun ofText(text: String) = Content(text = text) @JvmStatic - fun ofArray(array: List) = - Content(array = array) + fun ofArray(array: List) = Content(array = array) } /** - * An interface that defines how to map each variant of [Content] to a value - * of type [T]. + * An interface that defines how to map each variant of [Content] to a value of + * type [T]. */ interface Visitor { @@ -1965,70 +2055,58 @@ private constructor( /** * Maps an unknown variant of [Content] to a value of type [T]. * - * An instance of [Content] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new variants that the SDK is unaware of. + * An instance of [Content] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } internal class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>(), - ) { - it.forEach { it.validate() } - } - ?.let { - return Content(array = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Content(array = it, _json = json) + } - return Content(_json = json) + return Content(_json = json) } } internal class Serializer : BaseSerializer(Content::class) { - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( + class ChatCompletionContentPart private constructor( private val text: ChatCompletionContentPartText? = null, private val image: ChatCompletionContentPartImage? = null, private val _json: JsonValue? = null, + ) { - fun text(): Optional = - Optional.ofNullable(text) + fun text(): Optional = Optional.ofNullable(text) - fun image(): Optional = - Optional.ofNullable(image) + fun image(): Optional = Optional.ofNullable(image) fun isText(): Boolean = text != null @@ -2036,50 +2114,44 @@ private constructor( fun asText(): ChatCompletionContentPartText = text.getOrThrow("text") - fun asImage(): ChatCompletionContentPartImage = - image.getOrThrow("image") + fun asImage(): ChatCompletionContentPartImage = image.getOrThrow("image") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - image != null -> visitor.visitImage(image) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ChatCompletionContentPart = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPart = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitText( - text: ChatCompletionContentPartText - ) { - text.validate() + accept(object : Visitor { + override fun visitText(text: ChatCompletionContentPartText) { + text.validate() } - override fun visitImage( - image: ChatCompletionContentPartImage - ) { - image.validate() + override fun visitImage(image: ChatCompletionContentPartImage) { + image.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, image) /* spotless:on */ @@ -2089,26 +2161,21 @@ private constructor( text != null -> "ChatCompletionContentPart{text=$text}" image != null -> "ChatCompletionContentPart{image=$image}" _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") } companion object { @JvmStatic - fun ofText(text: ChatCompletionContentPartText) = - ChatCompletionContentPart(text = text) + fun ofText(text: ChatCompletionContentPartText) = ChatCompletionContentPart(text = text) @JvmStatic - fun ofImage(image: ChatCompletionContentPartImage) = - ChatCompletionContentPart(image = image) + fun ofImage(image: ChatCompletionContentPartImage) = ChatCompletionContentPart(image = image) } /** - * An interface that defines how to map each variant of - * [ChatCompletionContentPart] to a value of type [T]. + * An interface that defines how to map each variant of [ChatCompletionContentPart] + * to a value of type [T]. */ interface Visitor { @@ -2117,94 +2184,56 @@ private constructor( fun visitImage(image: ChatCompletionContentPartImage): T /** - * Maps an unknown variant of [ChatCompletionContentPart] to a value - * of type [T]. + * Maps an unknown variant of [ChatCompletionContentPart] to a value of type [T]. * - * An instance of [ChatCompletionContentPart] can contain an unknown - * variant if it was deserialized from data that doesn't match any - * known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [ChatCompletionContentPart] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * - * @throws BraintrustInvalidDataException in the default - * implementation. + * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") } } - internal class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - text = it, - _json = json, - ) - } - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - image = it, - _json = json, - ) - } + internal class Deserializer : BaseDeserializer(ChatCompletionContentPart::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) - return ChatCompletionContentPart(_json = json) + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ChatCompletionContentPart(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ChatCompletionContentPart(image = it, _json = json) + } + + return ChatCompletionContentPart(_json = json) } } - internal class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.image != null -> generator.writeObject(value.image) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) - } + internal class Serializer : BaseSerializer(ChatCompletionContentPart::class) { + + override fun serialize(value: ChatCompletionContentPart, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2213,48 +2242,33 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Assistant - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("function_call") - @ExcludeMissing - private val functionCall: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tool_calls") - @ExcludeMissing - private val toolCalls: JsonField> = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Assistant @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("tool_calls") @ExcludeMissing private val toolCalls: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -2264,7 +2278,9 @@ private constructor( @ExcludeMissing fun _functionCall(): JsonField = functionCall - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("tool_calls") @ExcludeMissing @@ -2276,18 +2292,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Assistant = apply { - if (validated) { - return@apply - } + fun validate(): Assistant = + apply { + if (validated) { + return@apply + } - role() - content() - functionCall().ifPresent { it.validate() } - name() - toolCalls().ifPresent { it.forEach { it.validate() } } - validated = true - } + role() + content() + functionCall().ifPresent { it.validate() } + name() + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true + } fun toBuilder() = Builder().from(this) @@ -2297,11 +2314,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Assistant]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Assistant]. */ @@ -2311,65 +2330,69 @@ private constructor( private var content: JsonField = JsonMissing.of() private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var toolCalls: - JsonField>? = - null - private var additionalProperties: MutableMap = - mutableMapOf() + private var toolCalls: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(assistant: Assistant) = apply { - role = assistant.role - content = assistant.content - functionCall = assistant.functionCall - name = assistant.name - toolCalls = assistant.toolCalls.map { it.toMutableList() } - additionalProperties = assistant.additionalProperties.toMutableMap() - } + internal fun from(assistant: Assistant) = + apply { + role = assistant.role + content = assistant.content + functionCall = assistant.functionCall + name = assistant.name + toolCalls = assistant.toolCalls.map { it.toMutableList() } + additionalProperties = assistant.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } - fun functionCall(functionCall: FunctionCall?) = - functionCall(JsonField.ofNullable(functionCall)) + fun functionCall(functionCall: FunctionCall?) = functionCall(JsonField.ofNullable(functionCall)) - fun functionCall(functionCall: Optional) = - functionCall(functionCall.getOrNull()) + fun functionCall(functionCall: Optional) = functionCall(functionCall.getOrNull()) - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } + fun functionCall(functionCall: JsonField) = + apply { + this.functionCall = functionCall + } fun name(name: String?) = name(JsonField.ofNullable(name)) fun name(name: Optional) = name(name.getOrNull()) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun toolCalls(toolCalls: List?) = - toolCalls(JsonField.ofNullable(toolCalls)) + fun toolCalls(toolCalls: List?) = toolCalls(JsonField.ofNullable(toolCalls)) - fun toolCalls(toolCalls: Optional>) = - toolCalls(toolCalls.getOrNull()) + fun toolCalls(toolCalls: Optional>) = toolCalls(toolCalls.getOrNull()) fun toolCalls(toolCalls: JsonField>) = apply { this.toolCalls = toolCalls.map { it.toMutableList() } } - fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { - toolCalls = - (toolCalls ?: JsonField.of(mutableListOf())).also { + fun addToolCall(toolCall: ChatCompletionMessageToolCall) = + apply { + toolCalls = (toolCalls ?: JsonField.of(mutableListOf())).also { checkKnown("toolCalls", it).add(toolCall) } - } + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2377,44 +2400,51 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Assistant = Assistant( - checkRequired("role", role), - content, - functionCall, - name, - (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + functionCall, + name, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -2428,25 +2458,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - ASSISTANT + ASSISTANT, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { ASSISTANT, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2454,8 +2482,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2466,11 +2494,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2481,23 +2509,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2506,18 +2531,11 @@ private constructor( } @NoAutoDetect - class FunctionCall - @JsonCreator - private constructor( - @JsonProperty("arguments") - @ExcludeMissing - private val arguments: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class FunctionCall @JsonCreator private constructor( + @JsonProperty("arguments") @ExcludeMissing private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun arguments(): String = arguments.getRequired("arguments") @@ -2528,7 +2546,9 @@ private constructor( @ExcludeMissing fun _arguments(): JsonField = arguments - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2536,31 +2556,33 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionCall = apply { - if (validated) { - return@apply - } + fun validate(): FunctionCall = + apply { + if (validated) { + return@apply + } - arguments() - name() - validated = true - } + arguments() + name() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [FunctionCall]. + * Returns a mutable builder for constructing an instance of [FunctionCall]. * * The following fields are required: + * * ```java * .arguments() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionCall]. */ @@ -2568,26 +2590,29 @@ private constructor( private var arguments: JsonField? = null private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - arguments = functionCall.arguments - name = functionCall.name - additionalProperties = - functionCall.additionalProperties.toMutableMap() - } + internal fun from(functionCall: FunctionCall) = + apply { + arguments = functionCall.arguments + name = functionCall.name + additionalProperties = functionCall.additionalProperties.toMutableMap() + } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } + fun arguments(arguments: JsonField) = + apply { + this.arguments = arguments + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2595,36 +2620,44 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionCall = FunctionCall( - checkRequired("arguments", arguments), - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "arguments", arguments + ), + checkRequired( + "name", name + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2633,16 +2666,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2651,36 +2683,27 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Tool - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("tool_call_id") - @ExcludeMissing - private val toolCallId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Tool @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("tool_call_id") @ExcludeMissing private val toolCallId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun toolCallId(): Optional = - Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -2696,16 +2719,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Tool = apply { - if (validated) { - return@apply - } + fun validate(): Tool = + apply { + if (validated) { + return@apply + } - role() - content() - toolCallId() - validated = true - } + role() + content() + toolCallId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2715,11 +2739,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Tool]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Tool]. */ @@ -2728,30 +2754,37 @@ private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tool: Tool) = apply { - role = tool.role - content = tool.content - toolCallId = tool.toolCallId - additionalProperties = tool.additionalProperties.toMutableMap() - } + internal fun from(tool: Tool) = + apply { + role = tool.role + content = tool.content + toolCallId = tool.toolCallId + additionalProperties = tool.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } + fun toolCallId(toolCallId: JsonField) = + apply { + this.toolCallId = toolCallId + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2759,42 +2792,49 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Tool = Tool( - checkRequired("role", role), - content, - toolCallId, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + toolCallId, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -2808,25 +2848,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - TOOL + TOOL, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { TOOL, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2834,8 +2872,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2846,11 +2884,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2861,23 +2899,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2886,11 +2921,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2899,37 +2934,31 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -2941,16 +2970,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - name() - role() - content() - validated = true - } + name() + role() + content() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2960,12 +2990,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .name() * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -2974,28 +3006,37 @@ private constructor( private var name: JsonField? = null private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - name = function.name - role = function.role - content = function.content - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + name = function.name + role = function.role + content = function.content + additionalProperties = function.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun additionalProperties(additionalProperties: Map) = apply { @@ -3003,42 +3044,51 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("name", name), - checkRequired("role", role), - content, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "role", role + ), + content, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -3052,25 +3102,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { FUNCTION, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -3078,8 +3126,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -3090,11 +3138,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -3105,23 +3153,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3130,11 +3175,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3143,30 +3188,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Fallback - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Fallback @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -3178,15 +3217,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Fallback = apply { - if (validated) { - return@apply - } + fun validate(): Fallback = + apply { + if (validated) { + return@apply + } - role() - content() - validated = true - } + role() + content() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3196,11 +3236,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Fallback]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Fallback]. */ @@ -3208,25 +3250,31 @@ private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fallback: Fallback) = apply { - role = fallback.role - content = fallback.content - additionalProperties = fallback.additionalProperties.toMutableMap() - } + internal fun from(fallback: Fallback) = + apply { + role = fallback.role + content = fallback.content + additionalProperties = fallback.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun additionalProperties(additionalProperties: Map) = apply { @@ -3234,41 +3282,48 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Fallback = Fallback( - checkRequired("role", role), - content, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -3282,25 +3337,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - MODEL + MODEL, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { MODEL, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -3308,8 +3361,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -3320,11 +3373,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -3335,23 +3388,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3360,11 +3410,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3373,13 +3423,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -3389,7 +3440,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -3400,23 +3452,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CHAT + CHAT, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { CHAT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -3440,7 +3492,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3455,19 +3507,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3476,11 +3525,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Chat && messages == other.messages && type == other.type && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Chat && messages == other.messages && type == other.type && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3489,16 +3538,13 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Chat{messages=$messages, type=$type, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = "Chat{messages=$messages, type=$type, tools=$tools, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -3507,20 +3553,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -3529,41 +3577,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3578,11 +3631,11 @@ private constructor( @JsonDeserialize(using = ToolFunction.Deserializer::class) @JsonSerialize(using = ToolFunction.Serializer::class) - class ToolFunction - private constructor( + class ToolFunction private constructor( private val function: Function? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun function(): Optional = Optional.ofNullable(function) @@ -3600,40 +3653,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - function != null -> visitor.visitFunction(function) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + function != null -> visitor.visitFunction(function) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ToolFunction = apply { - if (validated) { - return@apply - } + fun validate(): ToolFunction = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ToolFunction && function == other.function && global == other.global /* spotless:on */ + return /* spotless:off */ other is ToolFunction && function == other.function && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(function, global) /* spotless:on */ @@ -3648,14 +3700,16 @@ private constructor( companion object { - @JvmStatic fun ofFunction(function: Function) = ToolFunction(function = function) + @JvmStatic + fun ofFunction(function: Function) = ToolFunction(function = function) - @JvmStatic fun ofGlobal(global: Global) = ToolFunction(global = global) + @JvmStatic + fun ofGlobal(global: Global) = ToolFunction(global = global) } /** - * An interface that defines how to map each variant of [ToolFunction] to a value of type - * [T]. + * An interface that defines how to map each variant of [ToolFunction] to a value + * of type [T]. */ interface Visitor { @@ -3666,73 +3720,65 @@ private constructor( /** * Maps an unknown variant of [ToolFunction] to a value of type [T]. * - * An instance of [ToolFunction] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [ToolFunction] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolFunction: $json") + throw BraintrustInvalidDataException("Unknown ToolFunction: $json") } } internal class Deserializer : BaseDeserializer(ToolFunction::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolFunction { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolFunction(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolFunction(global = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ToolFunction(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ToolFunction(global = it, _json = json) + } - return ToolFunction(_json = json) + return ToolFunction(_json = json) } } internal class Serializer : BaseSerializer(ToolFunction::class) { - override fun serialize( - value: ToolFunction, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.function != null -> generator.writeObject(value.function) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolFunction") - } + override fun serialize(value: ToolFunction, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.function != null -> generator.writeObject(value.function) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolFunction") + } } } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun id(): String = id.getRequired("id") fun type(): Type = type.getRequired("type") - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3740,15 +3786,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - id() - type() - validated = true - } + id() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3758,12 +3805,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .id() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -3774,52 +3823,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - id = function.id - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + id = function.id + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("id", id), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -3829,7 +3895,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -3840,23 +3907,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { FUNCTION, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -3880,7 +3947,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3895,19 +3962,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3916,11 +3980,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3929,31 +3993,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3961,15 +4022,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3979,12 +4041,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -3995,52 +4059,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -4050,7 +4131,8 @@ private constructor( * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -4061,23 +4143,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4101,7 +4183,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -4116,19 +4198,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4137,11 +4216,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4150,17 +4229,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptData && options == other.options && origin == other.origin && parser == other.parser && prompt == other.prompt && toolFunctions == other.toolFunctions && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptData && options == other.options && origin == other.origin && parser == other.parser && prompt == other.prompt && toolFunctions == other.toolFunctions && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4169,6 +4247,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PromptData{options=$options, origin=$origin, parser=$parser, prompt=$prompt, toolFunctions=$toolFunctions, additionalProperties=$additionalProperties}" + override fun toString() = "PromptData{options=$options, origin=$origin, parser=$parser, prompt=$prompt, toolFunctions=$toolFunctions, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index a76243f9..54c1ceb1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a prompt object by its id */ -class PromptDeleteParams -private constructor( +class PromptDeleteParams private constructor( private val promptId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Prompt id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptDeleteParams]. * * The following fields are required: + * * ```java * .promptId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptDeleteParams: PromptDeleteParams) = apply { - promptId = promptDeleteParams.promptId - additionalHeaders = promptDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = promptDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = promptDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(promptDeleteParams: PromptDeleteParams) = + apply { + promptId = promptDeleteParams.promptId + additionalHeaders = promptDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = promptDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = promptDeleteParams.additionalBodyProperties.toMutableMap() + } /** Prompt id */ - fun promptId(promptId: String) = apply { this.promptId = promptId } + fun promptId(promptId: String) = + apply { + this.promptId = promptId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): PromptDeleteParams = PromptDeleteParams( - checkRequired("promptId", promptId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "promptId", promptId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptDeleteParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptDeleteParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index a54dbe4f..1054845e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.PromptService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ -class PromptListPage -private constructor( +class PromptListPage private constructor( private val promptsService: PromptService, private val params: PromptListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptListPage && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is PromptListPage && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ - override fun toString() = - "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" + override fun toString() = "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(PromptListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(PromptListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { promptsService.list(it) } + return getNextPageParams().map { promptsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(promptsService: PromptService, params: PromptListParams, response: Response) = - PromptListPage(promptsService, params, response) + PromptListPage( + promptsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [PromptListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: PromptListPage) : Iterable { + class AutoPager( + private val firstPage: PromptListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index 940430e6..06a4044a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.PromptServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ -class PromptListPageAsync -private constructor( +class PromptListPageAsync private constructor( private val promptsService: PromptServiceAsync, private val params: PromptListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptListPageAsync && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is PromptListPageAsync && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ - override fun toString() = - "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" + override fun toString() = "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(PromptListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(PromptListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { promptsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + promptsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(promptsService: PromptServiceAsync, params: PromptListParams, response: Response) = - PromptListPageAsync(promptsService, params, response) + PromptListPageAsync( + promptsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [PromptListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: PromptListPageAsync) { + class AutoPager( + private val firstPage: PromptListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Prompt) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Prompt) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index ab888cab..725c3bce 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ -class PromptListParams -private constructor( +class PromptListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -40,20 +39,21 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -78,17 +78,17 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ fun version(): Optional = Optional.ofNullable(version) @@ -99,29 +99,71 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.promptName?.let { queryParams.put("prompt_name", listOf(it.toString())) } - this.slug?.let { queryParams.put("slug", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.promptName?.let { + queryParams.put( + "prompt_name", listOf(it.toString()) + ) + } + this.slug?.let { + queryParams.put( + "slug", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): PromptListParams = builder().build() + @JvmStatic + fun none(): PromptListParams = builder().build() /** Returns a mutable builder for constructing an instance of [PromptListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptListParams]. */ @@ -142,65 +184,75 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptListParams: PromptListParams) = apply { - endingBefore = promptListParams.endingBefore - ids = promptListParams.ids - limit = promptListParams.limit - orgName = promptListParams.orgName - projectId = promptListParams.projectId - projectName = promptListParams.projectName - promptName = promptListParams.promptName - slug = promptListParams.slug - startingAfter = promptListParams.startingAfter - version = promptListParams.version - additionalHeaders = promptListParams.additionalHeaders.toBuilder() - additionalQueryParams = promptListParams.additionalQueryParams.toBuilder() - } + internal fun from(promptListParams: PromptListParams) = + apply { + endingBefore = promptListParams.endingBefore + ids = promptListParams.ids + limit = promptListParams.limit + orgName = promptListParams.orgName + projectId = promptListParams.projectId + projectName = promptListParams.projectName + promptName = promptListParams.promptName + slug = promptListParams.slug + startingAfter = promptListParams.startingAfter + version = promptListParams.version + additionalHeaders = promptListParams.additionalHeaders.toBuilder() + additionalQueryParams = promptListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -209,31 +261,46 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the prompt to search for */ - fun promptName(promptName: String?) = apply { this.promptName = promptName } + fun promptName(promptName: String?) = + apply { + this.promptName = promptName + } /** Name of the prompt to search for */ fun promptName(promptName: Optional) = promptName(promptName.getOrNull()) /** Retrieve prompt with a specific slug */ - fun slug(slug: String?) = apply { this.slug = slug } + fun slug(slug: String?) = + apply { + this.slug = slug + } /** Retrieve prompt with a specific slug */ fun slug(slug: Optional) = slug(slug.getOrNull()) @@ -241,164 +308,195 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptListParams = PromptListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - promptName, - slug, - startingAfter, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + promptName, + slug, + startingAfter, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -416,19 +514,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -443,12 +541,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -458,60 +561,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && promptName == other.promptName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && promptName == other.promptName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 5ac95496..0c5160f5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -32,17 +32,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class PromptOptions -@JsonCreator -private constructor( +class PromptOptions @JsonCreator private constructor( @JsonProperty("model") @ExcludeMissing private val model: JsonField = JsonMissing.of(), - @JsonProperty("params") - @ExcludeMissing - private val params: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), + @JsonProperty("params") @ExcludeMissing private val params: JsonField = JsonMissing.of(), + @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun model(): Optional = Optional.ofNullable(model.getNullable("model")) @@ -51,11 +46,17 @@ private constructor( fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonProperty("model") + @ExcludeMissing + fun _model(): JsonField = model - @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params + @JsonProperty("params") + @ExcludeMissing + fun _params(): JsonField = params - @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position @JsonAnyGetter @ExcludeMissing @@ -63,23 +64,25 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptOptions = apply { - if (validated) { - return@apply - } + fun validate(): PromptOptions = + apply { + if (validated) { + return@apply + } - model() - params().ifPresent { it.validate() } - position() - validated = true - } + model() + params().ifPresent { it.validate() } + position() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [PromptOptions]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptOptions]. */ @@ -91,73 +94,90 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptOptions: PromptOptions) = apply { - model = promptOptions.model - params = promptOptions.params - position = promptOptions.position - additionalProperties = promptOptions.additionalProperties.toMutableMap() - } + internal fun from(promptOptions: PromptOptions) = + apply { + model = promptOptions.model + params = promptOptions.params + position = promptOptions.position + additionalProperties = promptOptions.additionalProperties.toMutableMap() + } fun model(model: String) = model(JsonField.of(model)) - fun model(model: JsonField) = apply { this.model = model } + fun model(model: JsonField) = + apply { + this.model = model + } fun params(params: Params) = params(JsonField.of(params)) - fun params(params: JsonField) = apply { this.params = params } + fun params(params: JsonField) = + apply { + this.params = params + } - fun params(openaiModel: Params.OpenAIModelParams) = - params(Params.ofOpenAIModel(openaiModel)) + fun params(openaiModel: Params.OpenAIModelParams) = params(Params.ofOpenAIModel(openaiModel)) - fun params(anthropicModel: Params.AnthropicModelParams) = - params(Params.ofAnthropicModel(anthropicModel)) + fun params(anthropicModel: Params.AnthropicModelParams) = params(Params.ofAnthropicModel(anthropicModel)) - fun params(googleModel: Params.GoogleModelParams) = - params(Params.ofGoogleModel(googleModel)) + fun params(googleModel: Params.GoogleModelParams) = params(Params.ofGoogleModel(googleModel)) - fun params(windowAiModel: Params.WindowAiModelParams) = - params(Params.ofWindowAiModel(windowAiModel)) + fun params(windowAiModel: Params.WindowAiModelParams) = params(Params.ofWindowAiModel(windowAiModel)) - fun params(jsCompletion: Params.JsCompletionParams) = - params(Params.ofJsCompletion(jsCompletion)) + fun params(jsCompletion: Params.JsCompletionParams) = params(Params.ofJsCompletion(jsCompletion)) fun position(position: String) = position(JsonField.of(position)) - fun position(position: JsonField) = apply { this.position = position } + fun position(position: JsonField) = + apply { + this.position = position + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptOptions = - PromptOptions(model, params, position, additionalProperties.toImmutable()) + PromptOptions( + model, + params, + position, + additionalProperties.toImmutable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params - private constructor( + class Params private constructor( private val openaiModel: OpenAIModelParams? = null, private val anthropicModel: AnthropicModelParams? = null, private val googleModel: GoogleModelParams? = null, private val windowAiModel: WindowAiModelParams? = null, private val jsCompletion: JsCompletionParams? = null, private val _json: JsonValue? = null, + ) { fun openaiModel(): Optional = Optional.ofNullable(openaiModel) @@ -193,55 +213,54 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - openaiModel != null -> visitor.visitOpenAIModel(openaiModel) - anthropicModel != null -> visitor.visitAnthropicModel(anthropicModel) - googleModel != null -> visitor.visitGoogleModel(googleModel) - windowAiModel != null -> visitor.visitWindowAiModel(windowAiModel) - jsCompletion != null -> visitor.visitJsCompletion(jsCompletion) - else -> visitor.unknown(_json) - } + return when { + openaiModel != null -> visitor.visitOpenAIModel(openaiModel) + anthropicModel != null -> visitor.visitAnthropicModel(anthropicModel) + googleModel != null -> visitor.visitGoogleModel(googleModel) + windowAiModel != null -> visitor.visitWindowAiModel(windowAiModel) + jsCompletion != null -> visitor.visitJsCompletion(jsCompletion) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Params = apply { - if (validated) { - return@apply - } + fun validate(): Params = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitOpenAIModel(openaiModel: OpenAIModelParams) { - openaiModel.validate() + openaiModel.validate() } override fun visitAnthropicModel(anthropicModel: AnthropicModelParams) { - anthropicModel.validate() + anthropicModel.validate() } override fun visitGoogleModel(googleModel: GoogleModelParams) { - googleModel.validate() + googleModel.validate() } override fun visitWindowAiModel(windowAiModel: WindowAiModelParams) { - windowAiModel.validate() + windowAiModel.validate() } override fun visitJsCompletion(jsCompletion: JsCompletionParams) { - jsCompletion.validate() + jsCompletion.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Params && openaiModel == other.openaiModel && anthropicModel == other.anthropicModel && googleModel == other.googleModel && windowAiModel == other.windowAiModel && jsCompletion == other.jsCompletion /* spotless:on */ + return /* spotless:off */ other is Params && openaiModel == other.openaiModel && anthropicModel == other.anthropicModel && googleModel == other.googleModel && windowAiModel == other.windowAiModel && jsCompletion == other.jsCompletion /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(openaiModel, anthropicModel, googleModel, windowAiModel, jsCompletion) /* spotless:on */ @@ -263,22 +282,22 @@ private constructor( fun ofOpenAIModel(openaiModel: OpenAIModelParams) = Params(openaiModel = openaiModel) @JvmStatic - fun ofAnthropicModel(anthropicModel: AnthropicModelParams) = - Params(anthropicModel = anthropicModel) + fun ofAnthropicModel(anthropicModel: AnthropicModelParams) = Params(anthropicModel = anthropicModel) @JvmStatic fun ofGoogleModel(googleModel: GoogleModelParams) = Params(googleModel = googleModel) @JvmStatic - fun ofWindowAiModel(windowAiModel: WindowAiModelParams) = - Params(windowAiModel = windowAiModel) + fun ofWindowAiModel(windowAiModel: WindowAiModelParams) = Params(windowAiModel = windowAiModel) @JvmStatic - fun ofJsCompletion(jsCompletion: JsCompletionParams) = - Params(jsCompletion = jsCompletion) + fun ofJsCompletion(jsCompletion: JsCompletionParams) = Params(jsCompletion = jsCompletion) } - /** An interface that defines how to map each variant of [Params] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Params] to a value of type + * [T]. + */ interface Visitor { fun visitOpenAIModel(openaiModel: OpenAIModelParams): T @@ -294,135 +313,96 @@ private constructor( /** * Maps an unknown variant of [Params] to a value of type [T]. * - * An instance of [Params] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Params] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } internal class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(openaiModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(anthropicModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(googleModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(windowAiModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(jsCompletion = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(openaiModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(anthropicModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(googleModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(windowAiModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(jsCompletion = it, _json = json) + } + + return Params(_json = json) } } internal class Serializer : BaseSerializer(Params::class) { - override fun serialize( - value: Params, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.openaiModel != null -> generator.writeObject(value.openaiModel) - value.anthropicModel != null -> generator.writeObject(value.anthropicModel) - value.googleModel != null -> generator.writeObject(value.googleModel) - value.windowAiModel != null -> generator.writeObject(value.windowAiModel) - value.jsCompletion != null -> generator.writeObject(value.jsCompletion) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.openaiModel != null -> generator.writeObject(value.openaiModel) + value.anthropicModel != null -> generator.writeObject(value.anthropicModel) + value.googleModel != null -> generator.writeObject(value.googleModel) + value.windowAiModel != null -> generator.writeObject(value.windowAiModel) + value.jsCompletion != null -> generator.writeObject(value.jsCompletion) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } @NoAutoDetect - class OpenAIModelParams - @JsonCreator - private constructor( - @JsonProperty("frequency_penalty") - @ExcludeMissing - private val frequencyPenalty: JsonField = JsonMissing.of(), - @JsonProperty("function_call") - @ExcludeMissing - private val functionCall: JsonField = JsonMissing.of(), - @JsonProperty("max_tokens") - @ExcludeMissing - private val maxTokens: JsonField = JsonMissing.of(), + class OpenAIModelParams @JsonCreator private constructor( + @JsonProperty("frequency_penalty") @ExcludeMissing private val frequencyPenalty: JsonField = JsonMissing.of(), + @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens") @ExcludeMissing private val maxTokens: JsonField = JsonMissing.of(), @JsonProperty("n") @ExcludeMissing private val n: JsonField = JsonMissing.of(), - @JsonProperty("presence_penalty") - @ExcludeMissing - private val presencePenalty: JsonField = JsonMissing.of(), - @JsonProperty("response_format") - @ExcludeMissing - private val responseFormat: JsonField = JsonMissing.of(), - @JsonProperty("stop") - @ExcludeMissing - private val stop: JsonField> = JsonMissing.of(), - @JsonProperty("temperature") - @ExcludeMissing - private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("tool_choice") - @ExcludeMissing - private val toolChoice: JsonField = JsonMissing.of(), - @JsonProperty("top_p") - @ExcludeMissing - private val topP: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("presence_penalty") @ExcludeMissing private val presencePenalty: JsonField = JsonMissing.of(), + @JsonProperty("response_format") @ExcludeMissing private val responseFormat: JsonField = JsonMissing.of(), + @JsonProperty("stop") @ExcludeMissing private val stop: JsonField> = JsonMissing.of(), + @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("tool_choice") @ExcludeMissing private val toolChoice: JsonField = JsonMissing.of(), + @JsonProperty("top_p") @ExcludeMissing private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun frequencyPenalty(): Optional = - Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) - fun maxTokens(): Optional = - Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun presencePenalty(): Optional = - Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = - Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) - fun toolChoice(): Optional = - Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -436,7 +416,9 @@ private constructor( @ExcludeMissing fun _maxTokens(): JsonField = maxTokens - @JsonProperty("n") @ExcludeMissing fun _n(): JsonField = n + @JsonProperty("n") + @ExcludeMissing + fun _n(): JsonField = n @JsonProperty("presence_penalty") @ExcludeMissing @@ -446,7 +428,9 @@ private constructor( @ExcludeMissing fun _responseFormat(): JsonField = responseFormat - @JsonProperty("stop") @ExcludeMissing fun _stop(): JsonField> = stop + @JsonProperty("stop") + @ExcludeMissing + fun _stop(): JsonField> = stop @JsonProperty("temperature") @ExcludeMissing @@ -456,7 +440,9 @@ private constructor( @ExcludeMissing fun _toolChoice(): JsonField = toolChoice - @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + @JsonProperty("top_p") + @ExcludeMissing + fun _topP(): JsonField = topP @JsonProperty("use_cache") @ExcludeMissing @@ -468,33 +454,33 @@ private constructor( private var validated: Boolean = false - fun validate(): OpenAIModelParams = apply { - if (validated) { - return@apply + fun validate(): OpenAIModelParams = + apply { + if (validated) { + return@apply + } + + frequencyPenalty() + functionCall().ifPresent { it.validate() } + maxTokens() + n() + presencePenalty() + responseFormat().ifPresent { it.validate() } + stop() + temperature() + toolChoice().ifPresent { it.validate() } + topP() + useCache() + validated = true } - frequencyPenalty() - functionCall().ifPresent { it.validate() } - maxTokens() - n() - presencePenalty() - responseFormat().ifPresent { it.validate() } - stop() - temperature() - toolChoice().ifPresent { it.validate() } - topP() - useCache() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [OpenAIModelParams]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [OpenAIModelParams]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [OpenAIModelParams]. */ @@ -514,160 +500,172 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(openaiModelParams: OpenAIModelParams) = apply { - frequencyPenalty = openaiModelParams.frequencyPenalty - functionCall = openaiModelParams.functionCall - maxTokens = openaiModelParams.maxTokens - n = openaiModelParams.n - presencePenalty = openaiModelParams.presencePenalty - responseFormat = openaiModelParams.responseFormat - stop = openaiModelParams.stop.map { it.toMutableList() } - temperature = openaiModelParams.temperature - toolChoice = openaiModelParams.toolChoice - topP = openaiModelParams.topP - useCache = openaiModelParams.useCache - additionalProperties = openaiModelParams.additionalProperties.toMutableMap() - } - - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) - - fun frequencyPenalty(frequencyPenalty: JsonField) = apply { - this.frequencyPenalty = frequencyPenalty - } + internal fun from(openaiModelParams: OpenAIModelParams) = + apply { + frequencyPenalty = openaiModelParams.frequencyPenalty + functionCall = openaiModelParams.functionCall + maxTokens = openaiModelParams.maxTokens + n = openaiModelParams.n + presencePenalty = openaiModelParams.presencePenalty + responseFormat = openaiModelParams.responseFormat + stop = openaiModelParams.stop.map { it.toMutableList() } + temperature = openaiModelParams.temperature + toolChoice = openaiModelParams.toolChoice + topP = openaiModelParams.topP + useCache = openaiModelParams.useCache + additionalProperties = openaiModelParams.additionalProperties.toMutableMap() + } + + fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + + fun frequencyPenalty(frequencyPenalty: JsonField) = + apply { + this.frequencyPenalty = frequencyPenalty + } - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } + fun functionCall(functionCall: JsonField) = + apply { + this.functionCall = functionCall + } - fun functionCall(unionMember0: FunctionCall.UnionMember0) = - functionCall(FunctionCall.ofUnionMember0(unionMember0)) + fun functionCall(unionMember0: FunctionCall.UnionMember0) = functionCall(FunctionCall.ofUnionMember0(unionMember0)) - fun functionCall(function: FunctionCall.Function) = - functionCall(FunctionCall.ofFunction(function)) + fun functionCall(function: FunctionCall.Function) = functionCall(FunctionCall.ofFunction(function)) fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + fun maxTokens(maxTokens: JsonField) = + apply { + this.maxTokens = maxTokens + } fun n(n: Double) = n(JsonField.of(n)) - fun n(n: JsonField) = apply { this.n = n } + fun n(n: JsonField) = + apply { + this.n = n + } - fun presencePenalty(presencePenalty: Double) = - presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) - fun presencePenalty(presencePenalty: JsonField) = apply { - this.presencePenalty = presencePenalty - } + fun presencePenalty(presencePenalty: JsonField) = + apply { + this.presencePenalty = presencePenalty + } - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) - fun responseFormat(responseFormat: JsonField) = apply { - this.responseFormat = responseFormat - } + fun responseFormat(responseFormat: JsonField) = + apply { + this.responseFormat = responseFormat + } - fun responseFormat(jsonObject: ResponseFormat.JsonObject) = - responseFormat(ResponseFormat.ofJsonObject(jsonObject)) + fun responseFormat(jsonObject: ResponseFormat.JsonObject) = responseFormat(ResponseFormat.ofJsonObject(jsonObject)) - fun responseFormat(jsonSchema: ResponseFormat.JsonSchema) = - responseFormat(ResponseFormat.ofJsonSchema(jsonSchema)) + fun responseFormat(jsonSchema: ResponseFormat.JsonSchema) = responseFormat(ResponseFormat.ofJsonSchema(jsonSchema)) - fun responseFormat(text: ResponseFormat.Text) = - responseFormat(ResponseFormat.ofText(text)) + fun responseFormat(text: ResponseFormat.Text) = responseFormat(ResponseFormat.ofText(text)) - fun responseFormat(nullableVariant: ResponseFormat.NullableVariant) = - responseFormat(ResponseFormat.ofNullableVariant(nullableVariant)) + fun responseFormat(nullableVariant: ResponseFormat.NullableVariant) = responseFormat(ResponseFormat.ofNullableVariant(nullableVariant)) fun stop(stop: List) = stop(JsonField.of(stop)) - fun stop(stop: JsonField>) = apply { - this.stop = stop.map { it.toMutableList() } - } + fun stop(stop: JsonField>) = + apply { + this.stop = stop.map { it.toMutableList() } + } - fun addStop(stop: String) = apply { - this.stop = - (this.stop ?: JsonField.of(mutableListOf())).also { + fun addStop(stop: String) = + apply { + this.stop = (this.stop ?: JsonField.of(mutableListOf())).also { checkKnown("stop", it).add(stop) } - } + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = + apply { + this.temperature = temperature + } fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) - fun toolChoice(toolChoice: JsonField) = apply { - this.toolChoice = toolChoice - } + fun toolChoice(toolChoice: JsonField) = + apply { + this.toolChoice = toolChoice + } - fun toolChoice(unionMember0: ToolChoice.UnionMember0) = - toolChoice(ToolChoice.ofUnionMember0(unionMember0)) + fun toolChoice(unionMember0: ToolChoice.UnionMember0) = toolChoice(ToolChoice.ofUnionMember0(unionMember0)) - fun toolChoice(function: ToolChoice.Function) = - toolChoice(ToolChoice.ofFunction(function)) + fun toolChoice(function: ToolChoice.Function) = toolChoice(ToolChoice.ofFunction(function)) fun topP(topP: Double) = topP(JsonField.of(topP)) - fun topP(topP: JsonField) = apply { this.topP = topP } + fun topP(topP: JsonField) = + apply { + this.topP = topP + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): OpenAIModelParams = OpenAIModelParams( - frequencyPenalty, - functionCall, - maxTokens, - n, - presencePenalty, - responseFormat, - (stop ?: JsonMissing.of()).map { it.toImmutable() }, - temperature, - toolChoice, - topP, - useCache, - additionalProperties.toImmutable(), + frequencyPenalty, + functionCall, + maxTokens, + n, + presencePenalty, + responseFormat, + (stop ?: JsonMissing.of()).map { it.toImmutable() }, + temperature, + toolChoice, + topP, + useCache, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall - private constructor( + class FunctionCall private constructor( private val unionMember0: UnionMember0? = null, private val function: Function? = null, private val _json: JsonValue? = null, + ) { fun unionMember0(): Optional = Optional.ofNullable(unionMember0) @@ -685,38 +683,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionCall = apply { - if (validated) { - return@apply - } + fun validate(): FunctionCall = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) {} + accept(object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + + } override fun visitFunction(function: Function) { - function.validate() + function.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCall && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ + return /* spotless:off */ other is FunctionCall && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, function) /* spotless:on */ @@ -732,16 +731,15 @@ private constructor( companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - FunctionCall(unionMember0 = unionMember0) + fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) @JvmStatic fun ofFunction(function: Function) = FunctionCall(function = function) } /** - * An interface that defines how to map each variant of [FunctionCall] to a value of - * type [T]. + * An interface that defines how to map each variant of [FunctionCall] to a value + * of type [T]. */ interface Visitor { @@ -753,61 +751,57 @@ private constructor( * Maps an unknown variant of [FunctionCall] to a value of type [T]. * * An instance of [FunctionCall] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } internal class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionCall(function = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(unionMember0 = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } internal class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize( - value: FunctionCall, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class UnionMember0 @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -831,19 +825,20 @@ private constructor( * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [UnionMember0] can contain an unknown value in a couple of - * cases: + * An instance of [UnionMember0] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { AUTO, NONE, /** - * An enum member indicating that [UnionMember0] was instantiated with an - * unknown value. + * An enum member indicating that [UnionMember0] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -852,8 +847,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -865,18 +860,17 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a - * not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { AUTO -> Known.AUTO NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException("Unknown UnionMember0: $value") + else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } /** @@ -885,20 +879,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does - * not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -907,19 +898,17 @@ private constructor( } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -927,14 +916,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - name() - validated = true - } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -944,29 +934,34 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ class Builder internal constructor() { private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - name = function.name - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + name = function.name + additionalProperties = function.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -974,35 +969,40 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1011,20 +1011,19 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" } } @JsonDeserialize(using = ResponseFormat.Deserializer::class) @JsonSerialize(using = ResponseFormat.Serializer::class) - class ResponseFormat - private constructor( + class ResponseFormat private constructor( private val jsonObject: JsonObject? = null, private val jsonSchema: JsonSchema? = null, private val text: Text? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { fun jsonObject(): Optional = Optional.ofNullable(jsonObject) @@ -1033,8 +1032,7 @@ private constructor( fun text(): Optional = Optional.ofNullable(text) - fun nullableVariant(): Optional = - Optional.ofNullable(nullableVariant) + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) fun isJsonObject(): Boolean = jsonObject != null @@ -1050,56 +1048,54 @@ private constructor( fun asText(): Text = text.getOrThrow("text") - fun asNullableVariant(): NullableVariant = - nullableVariant.getOrThrow("nullableVariant") + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - jsonObject != null -> visitor.visitJsonObject(jsonObject) - jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) - text != null -> visitor.visitText(text) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + jsonObject != null -> visitor.visitJsonObject(jsonObject) + jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) + text != null -> visitor.visitText(text) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ResponseFormat = apply { - if (validated) { - return@apply - } + fun validate(): ResponseFormat = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitJsonObject(jsonObject: JsonObject) { - jsonObject.validate() + jsonObject.validate() } override fun visitJsonSchema(jsonSchema: JsonSchema) { - jsonSchema.validate() + jsonSchema.validate() } override fun visitText(text: Text) { - text.validate() + text.validate() } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ @@ -1109,8 +1105,7 @@ private constructor( jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" text != null -> "ResponseFormat{text=$text}" - nullableVariant != null -> - "ResponseFormat{nullableVariant=$nullableVariant}" + nullableVariant != null -> "ResponseFormat{nullableVariant=$nullableVariant}" _json != null -> "ResponseFormat{_unknown=$_json}" else -> throw IllegalStateException("Invalid ResponseFormat") } @@ -1118,18 +1113,16 @@ private constructor( companion object { @JvmStatic - fun ofJsonObject(jsonObject: JsonObject) = - ResponseFormat(jsonObject = jsonObject) + fun ofJsonObject(jsonObject: JsonObject) = ResponseFormat(jsonObject = jsonObject) @JvmStatic - fun ofJsonSchema(jsonSchema: JsonSchema) = - ResponseFormat(jsonSchema = jsonSchema) + fun ofJsonSchema(jsonSchema: JsonSchema) = ResponseFormat(jsonSchema = jsonSchema) - @JvmStatic fun ofText(text: Text) = ResponseFormat(text = text) + @JvmStatic + fun ofText(text: Text) = ResponseFormat(text = text) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - ResponseFormat(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = ResponseFormat(nullableVariant = nullableVariant) } /** @@ -1150,77 +1143,65 @@ private constructor( * Maps an unknown variant of [ResponseFormat] to a value of type [T]. * * An instance of [ResponseFormat] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") + throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") } } - internal class Deserializer : - BaseDeserializer(ResponseFormat::class) { + internal class Deserializer : BaseDeserializer(ResponseFormat::class) { override fun ObjectCodec.deserialize(node: JsonNode): ResponseFormat { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(jsonObject = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(jsonSchema = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(nullableVariant = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ResponseFormat(jsonObject = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ResponseFormat(jsonSchema = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ResponseFormat(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ResponseFormat(nullableVariant = it, _json = json) + } - return ResponseFormat(_json = json) + return ResponseFormat(_json = json) } } internal class Serializer : BaseSerializer(ResponseFormat::class) { - override fun serialize( - value: ResponseFormat, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.jsonObject != null -> generator.writeObject(value.jsonObject) - value.jsonSchema != null -> generator.writeObject(value.jsonSchema) - value.text != null -> generator.writeObject(value.text) - value.nullableVariant != null -> - generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ResponseFormat") - } + override fun serialize(value: ResponseFormat, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.jsonObject != null -> generator.writeObject(value.jsonObject) + value.jsonSchema != null -> generator.writeObject(value.jsonSchema) + value.text != null -> generator.writeObject(value.text) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ResponseFormat") + } } } @NoAutoDetect - class JsonObject - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class JsonObject @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1228,14 +1209,15 @@ private constructor( private var validated: Boolean = false - fun validate(): JsonObject = apply { - if (validated) { - return@apply - } + fun validate(): JsonObject = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1245,29 +1227,34 @@ private constructor( * Returns a mutable builder for constructing an instance of [JsonObject]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [JsonObject]. */ class Builder internal constructor() { private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jsonObject: JsonObject) = apply { - type = jsonObject.type - additionalProperties = jsonObject.additionalProperties.toMutableMap() - } + internal fun from(jsonObject: JsonObject) = + apply { + type = jsonObject.type + additionalProperties = jsonObject.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1275,40 +1262,46 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): JsonObject = JsonObject( - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "type", type + ), additionalProperties.toImmutable() ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1322,25 +1315,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - JSON_OBJECT + JSON_OBJECT, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { JSON_OBJECT, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1348,8 +1339,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1360,11 +1351,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1375,23 +1366,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1400,11 +1388,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is JsonObject && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonObject && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1413,22 +1401,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "JsonObject{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "JsonObject{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class JsonSchema - @JsonCreator - private constructor( - @JsonProperty("json_schema") - @ExcludeMissing - private val jsonSchema: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class JsonSchema @JsonCreator private constructor( + @JsonProperty("json_schema") @ExcludeMissing private val jsonSchema: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun jsonSchema(): InnerJsonSchema = jsonSchema.getRequired("json_schema") @@ -1439,7 +1420,9 @@ private constructor( @ExcludeMissing fun _jsonSchema(): JsonField = jsonSchema - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1447,15 +1430,16 @@ private constructor( private var validated: Boolean = false - fun validate(): JsonSchema = apply { - if (validated) { - return@apply - } + fun validate(): JsonSchema = + apply { + if (validated) { + return@apply + } - jsonSchema().validate() - type() - validated = true - } + jsonSchema().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1465,12 +1449,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [JsonSchema]. * * The following fields are required: + * * ```java * .jsonSchema() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [JsonSchema]. */ @@ -1478,26 +1464,29 @@ private constructor( private var jsonSchema: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jsonSchema: JsonSchema) = apply { - this.jsonSchema = jsonSchema.jsonSchema - type = jsonSchema.type - additionalProperties = jsonSchema.additionalProperties.toMutableMap() - } + internal fun from(jsonSchema: JsonSchema) = + apply { + this.jsonSchema = jsonSchema.jsonSchema + type = jsonSchema.type + additionalProperties = jsonSchema.additionalProperties.toMutableMap() + } - fun jsonSchema(jsonSchema: InnerJsonSchema) = - jsonSchema(JsonField.of(jsonSchema)) + fun jsonSchema(jsonSchema: InnerJsonSchema) = jsonSchema(JsonField.of(jsonSchema)) - fun jsonSchema(jsonSchema: JsonField) = apply { - this.jsonSchema = jsonSchema - } + fun jsonSchema(jsonSchema: JsonField) = + apply { + this.jsonSchema = jsonSchema + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1505,63 +1494,59 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): JsonSchema = JsonSchema( - checkRequired("jsonSchema", jsonSchema), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "jsonSchema", jsonSchema + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InnerJsonSchema - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("schema") - @ExcludeMissing - private val schema: JsonField = JsonMissing.of(), - @JsonProperty("strict") - @ExcludeMissing - private val strict: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class InnerJsonSchema @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("schema") @ExcludeMissing private val schema: JsonField = JsonMissing.of(), + @JsonProperty("strict") @ExcludeMissing private val strict: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun schema(): Optional = - Optional.ofNullable(schema.getNullable("schema")) + fun schema(): Optional = Optional.ofNullable(schema.getNullable("schema")) - fun strict(): Optional = - Optional.ofNullable(strict.getNullable("strict")) + fun strict(): Optional = Optional.ofNullable(strict.getNullable("strict")) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("description") @ExcludeMissing @@ -1581,32 +1566,34 @@ private constructor( private var validated: Boolean = false - fun validate(): InnerJsonSchema = apply { - if (validated) { - return@apply - } + fun validate(): InnerJsonSchema = + apply { + if (validated) { + return@apply + } - name() - description() - schema().ifPresent { it.validate() } - strict() - validated = true - } + name() + description() + schema().ifPresent { it.validate() } + strict() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [InnerJsonSchema]. + * Returns a mutable builder for constructing an instance of [InnerJsonSchema]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InnerJsonSchema]. */ @@ -1616,33 +1603,38 @@ private constructor( private var description: JsonField = JsonMissing.of() private var schema: JsonField = JsonMissing.of() private var strict: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(innerJsonSchema: InnerJsonSchema) = apply { - name = innerJsonSchema.name - description = innerJsonSchema.description - schema = innerJsonSchema.schema - strict = innerJsonSchema.strict - additionalProperties = - innerJsonSchema.additionalProperties.toMutableMap() - } + internal fun from(innerJsonSchema: InnerJsonSchema) = + apply { + name = innerJsonSchema.name + description = innerJsonSchema.description + schema = innerJsonSchema.schema + strict = innerJsonSchema.strict + additionalProperties = innerJsonSchema.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun description(description: String) = - description(JsonField.of(description)) + fun description(description: String) = description(JsonField.of(description)) - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } fun schema(schema: Schema) = schema(JsonField.of(schema)) - fun schema(schema: JsonField) = apply { this.schema = schema } + fun schema(schema: JsonField) = + apply { + this.schema = schema + } fun strict(strict: Boolean?) = strict(JsonField.ofNullable(strict)) @@ -1650,7 +1642,10 @@ private constructor( fun strict(strict: Optional) = strict(strict.getOrNull()) - fun strict(strict: JsonField) = apply { this.strict = strict } + fun strict(strict: JsonField) = + apply { + this.strict = strict + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1658,111 +1653,114 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InnerJsonSchema = InnerJsonSchema( - checkRequired("name", name), - description, - schema, - strict, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + schema, + strict, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Schema - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap() + class Schema @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): Schema = apply { - if (validated) { - return@apply - } + fun validate(): Schema = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of - * [Schema]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [Schema]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [Schema]. */ class Builder internal constructor() { - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(schema: Schema) = apply { - additionalProperties = - schema.additionalProperties.toMutableMap() - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(schema: Schema) = + apply { + additionalProperties = schema.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Schema = Schema(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Schema && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schema && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1771,16 +1769,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Schema{additionalProperties=$additionalProperties}" + override fun toString() = "Schema{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InnerJsonSchema && name == other.name && description == other.description && schema == other.schema && strict == other.strict && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InnerJsonSchema && name == other.name && description == other.description && schema == other.schema && strict == other.strict && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1789,21 +1786,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InnerJsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" + override fun toString() = "InnerJsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -1817,25 +1814,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - JSON_SCHEMA + JSON_SCHEMA, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { JSON_SCHEMA, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1843,8 +1838,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1855,11 +1850,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1870,23 +1865,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1895,11 +1887,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is JsonSchema && jsonSchema == other.jsonSchema && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonSchema && jsonSchema == other.jsonSchema && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1908,24 +1900,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "JsonSchema{jsonSchema=$jsonSchema, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "JsonSchema{jsonSchema=$jsonSchema, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Text - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Text @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1933,14 +1922,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Text = apply { - if (validated) { - return@apply - } + fun validate(): Text = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1950,29 +1940,34 @@ private constructor( * Returns a mutable builder for constructing an instance of [Text]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Text]. */ class Builder internal constructor() { private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(text: Text) = apply { - type = text.type - additionalProperties = text.additionalProperties.toMutableMap() - } + internal fun from(text: Text) = + apply { + type = text.type + additionalProperties = text.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1980,37 +1975,46 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Text = - Text(checkRequired("type", type), additionalProperties.toImmutable()) + Text( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -2024,25 +2028,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - TEXT + TEXT, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { TEXT, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2050,8 +2052,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2062,11 +2064,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2077,23 +2079,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2102,11 +2101,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2115,16 +2114,13 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Text{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Text{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -2133,36 +2129,34 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of - * [NullableVariant]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ class Builder internal constructor() { - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = - nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2170,32 +2164,35 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toImmutable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2204,18 +2201,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "NullableVariant{additionalProperties=$additionalProperties}" + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( + class ToolChoice private constructor( private val unionMember0: UnionMember0? = null, private val function: Function? = null, private val _json: JsonValue? = null, + ) { fun unionMember0(): Optional = Optional.ofNullable(unionMember0) @@ -2233,38 +2229,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ToolChoice = apply { - if (validated) { - return@apply - } + fun validate(): ToolChoice = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) {} + accept(object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + + } override fun visitFunction(function: Function) { - function.validate() + function.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ToolChoice && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ + return /* spotless:off */ other is ToolChoice && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, function) /* spotless:on */ @@ -2280,10 +2277,10 @@ private constructor( companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - ToolChoice(unionMember0 = unionMember0) + fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) - @JvmStatic fun ofFunction(function: Function) = ToolChoice(function = function) + @JvmStatic + fun ofFunction(function: Function) = ToolChoice(function = function) } /** @@ -2300,61 +2297,57 @@ private constructor( * Maps an unknown variant of [ToolChoice] to a value of type [T]. * * An instance of [ToolChoice] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } internal class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolChoice(function = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(unionMember0 = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } internal class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class UnionMember0 @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -2381,11 +2374,12 @@ private constructor( * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [UnionMember0] can contain an unknown value in a couple of - * cases: + * An instance of [UnionMember0] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2393,8 +2387,8 @@ private constructor( NONE, REQUIRED, /** - * An enum member indicating that [UnionMember0] was instantiated with an - * unknown value. + * An enum member indicating that [UnionMember0] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -2403,8 +2397,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2417,19 +2411,18 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a - * not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { AUTO -> Known.AUTO NONE -> Known.NONE REQUIRED -> Known.REQUIRED - else -> - throw BraintrustInvalidDataException("Unknown UnionMember0: $value") + else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } /** @@ -2438,20 +2431,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does - * not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2460,17 +2450,11 @@ private constructor( } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("function") - @ExcludeMissing - private val function: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("function") @ExcludeMissing private val function: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun function(): InnerFunction = function.getRequired("function") @@ -2481,7 +2465,9 @@ private constructor( @ExcludeMissing fun _function(): JsonField = function - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2489,15 +2475,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - function().validate() - type() - validated = true - } + function().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2507,12 +2494,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .function() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -2520,25 +2509,29 @@ private constructor( private var function: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - this.function = function.function - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + this.function = function.function + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun function(function: InnerFunction) = function(JsonField.of(function)) - fun function(function: JsonField) = apply { - this.function = function - } + fun function(function: JsonField) = + apply { + this.function = function + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2546,45 +2539,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("function", function), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "function", function + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InnerFunction - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class InnerFunction @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2592,48 +2590,52 @@ private constructor( private var validated: Boolean = false - fun validate(): InnerFunction = apply { - if (validated) { - return@apply - } + fun validate(): InnerFunction = + apply { + if (validated) { + return@apply + } - name() - validated = true - } + name() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [InnerFunction]. + * Returns a mutable builder for constructing an instance of [InnerFunction]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InnerFunction]. */ class Builder internal constructor() { private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(innerFunction: InnerFunction) = apply { - name = innerFunction.name - additionalProperties = - innerFunction.additionalProperties.toMutableMap() - } + internal fun from(innerFunction: InnerFunction) = + apply { + name = innerFunction.name + additionalProperties = innerFunction.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2641,35 +2643,40 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InnerFunction = InnerFunction( - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InnerFunction && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InnerFunction && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2678,21 +2685,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InnerFunction{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InnerFunction{name=$name, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value @@ -2706,25 +2713,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: + * * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { FUNCTION, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2732,8 +2737,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -2744,11 +2749,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is - * a not a known member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2759,23 +2764,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value - * does not have the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2784,11 +2786,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2797,17 +2799,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Function{function=$function, type=$type, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2816,37 +2817,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class AnthropicModelParams - @JsonCreator - private constructor( - @JsonProperty("max_tokens") - @ExcludeMissing - private val maxTokens: JsonField = JsonMissing.of(), - @JsonProperty("temperature") - @ExcludeMissing - private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - private val maxTokensToSample: JsonField = JsonMissing.of(), - @JsonProperty("stop_sequences") - @ExcludeMissing - private val stopSequences: JsonField> = JsonMissing.of(), - @JsonProperty("top_k") - @ExcludeMissing - private val topK: JsonField = JsonMissing.of(), - @JsonProperty("top_p") - @ExcludeMissing - private val topP: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class AnthropicModelParams @JsonCreator private constructor( + @JsonProperty("max_tokens") @ExcludeMissing private val maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens_to_sample") @ExcludeMissing private val maxTokensToSample: JsonField = JsonMissing.of(), + @JsonProperty("stop_sequences") @ExcludeMissing private val stopSequences: JsonField> = JsonMissing.of(), + @JsonProperty("top_k") @ExcludeMissing private val topK: JsonField = JsonMissing.of(), + @JsonProperty("top_p") @ExcludeMissing private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -2854,18 +2838,15 @@ private constructor( fun temperature(): Double = temperature.getRequired("temperature") /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = - Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - fun stopSequences(): Optional> = - Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("max_tokens") @ExcludeMissing @@ -2884,9 +2865,13 @@ private constructor( @ExcludeMissing fun _stopSequences(): JsonField> = stopSequences - @JsonProperty("top_k") @ExcludeMissing fun _topK(): JsonField = topK + @JsonProperty("top_k") + @ExcludeMissing + fun _topK(): JsonField = topK - @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + @JsonProperty("top_p") + @ExcludeMissing + fun _topP(): JsonField = topP @JsonProperty("use_cache") @ExcludeMissing @@ -2898,35 +2883,39 @@ private constructor( private var validated: Boolean = false - fun validate(): AnthropicModelParams = apply { - if (validated) { - return@apply - } + fun validate(): AnthropicModelParams = + apply { + if (validated) { + return@apply + } - maxTokens() - temperature() - maxTokensToSample() - stopSequences() - topK() - topP() - useCache() - validated = true - } + maxTokens() + temperature() + maxTokensToSample() + stopSequences() + topK() + topP() + useCache() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [AnthropicModelParams]. + * Returns a mutable builder for constructing an instance of + * [AnthropicModelParams]. * * The following fields are required: + * * ```java * .maxTokens() * .temperature() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AnthropicModelParams]. */ @@ -2942,103 +2931,125 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(anthropicModelParams: AnthropicModelParams) = apply { - maxTokens = anthropicModelParams.maxTokens - temperature = anthropicModelParams.temperature - maxTokensToSample = anthropicModelParams.maxTokensToSample - stopSequences = anthropicModelParams.stopSequences.map { it.toMutableList() } - topK = anthropicModelParams.topK - topP = anthropicModelParams.topP - useCache = anthropicModelParams.useCache - additionalProperties = anthropicModelParams.additionalProperties.toMutableMap() - } + internal fun from(anthropicModelParams: AnthropicModelParams) = + apply { + maxTokens = anthropicModelParams.maxTokens + temperature = anthropicModelParams.temperature + maxTokensToSample = anthropicModelParams.maxTokensToSample + stopSequences = anthropicModelParams.stopSequences.map { it.toMutableList() } + topK = anthropicModelParams.topK + topP = anthropicModelParams.topP + useCache = anthropicModelParams.useCache + additionalProperties = anthropicModelParams.additionalProperties.toMutableMap() + } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + fun maxTokens(maxTokens: JsonField) = + apply { + this.maxTokens = maxTokens + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = + apply { + this.temperature = temperature + } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = - maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: JsonField) = apply { - this.maxTokensToSample = maxTokensToSample - } + fun maxTokensToSample(maxTokensToSample: JsonField) = + apply { + this.maxTokensToSample = maxTokensToSample + } - fun stopSequences(stopSequences: List) = - stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) - fun stopSequences(stopSequences: JsonField>) = apply { - this.stopSequences = stopSequences.map { it.toMutableList() } - } + fun stopSequences(stopSequences: JsonField>) = + apply { + this.stopSequences = stopSequences.map { it.toMutableList() } + } - fun addStopSequence(stopSequence: String) = apply { - stopSequences = - (stopSequences ?: JsonField.of(mutableListOf())).also { + fun addStopSequence(stopSequence: String) = + apply { + stopSequences = (stopSequences ?: JsonField.of(mutableListOf())).also { checkKnown("stopSequences", it).add(stopSequence) } - } + } fun topK(topK: Double) = topK(JsonField.of(topK)) - fun topK(topK: JsonField) = apply { this.topK = topK } + fun topK(topK: JsonField) = + apply { + this.topK = topK + } fun topP(topP: Double) = topP(JsonField.of(topP)) - fun topP(topP: JsonField) = apply { this.topP = topP } + fun topP(topP: JsonField) = + apply { + this.topP = topP + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AnthropicModelParams = AnthropicModelParams( - checkRequired("maxTokens", maxTokens), - checkRequired("temperature", temperature), - maxTokensToSample, - (stopSequences ?: JsonMissing.of()).map { it.toImmutable() }, - topK, - topP, - useCache, - additionalProperties.toImmutable(), + checkRequired( + "maxTokens", maxTokens + ), + checkRequired( + "temperature", temperature + ), + maxTokensToSample, + (stopSequences ?: JsonMissing.of()).map { it.toImmutable() }, + topK, + topP, + useCache, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AnthropicModelParams && maxTokens == other.maxTokens && temperature == other.temperature && maxTokensToSample == other.maxTokensToSample && stopSequences == other.stopSequences && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AnthropicModelParams && maxTokens == other.maxTokens && temperature == other.temperature && maxTokensToSample == other.maxTokensToSample && stopSequences == other.stopSequences && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3047,45 +3058,29 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AnthropicModelParams{maxTokens=$maxTokens, temperature=$temperature, maxTokensToSample=$maxTokensToSample, stopSequences=$stopSequences, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "AnthropicModelParams{maxTokens=$maxTokens, temperature=$temperature, maxTokensToSample=$maxTokensToSample, stopSequences=$stopSequences, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class GoogleModelParams - @JsonCreator - private constructor( - @JsonProperty("maxOutputTokens") - @ExcludeMissing - private val maxOutputTokens: JsonField = JsonMissing.of(), - @JsonProperty("temperature") - @ExcludeMissing - private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("topK") - @ExcludeMissing - private val topK: JsonField = JsonMissing.of(), - @JsonProperty("topP") - @ExcludeMissing - private val topP: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class GoogleModelParams @JsonCreator private constructor( + @JsonProperty("maxOutputTokens") @ExcludeMissing private val maxOutputTokens: JsonField = JsonMissing.of(), + @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("topK") @ExcludeMissing private val topK: JsonField = JsonMissing.of(), + @JsonProperty("topP") @ExcludeMissing private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun maxOutputTokens(): Optional = - Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -3095,9 +3090,13 @@ private constructor( @ExcludeMissing fun _temperature(): JsonField = temperature - @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK + @JsonProperty("topK") + @ExcludeMissing + fun _topK(): JsonField = topK - @JsonProperty("topP") @ExcludeMissing fun _topP(): JsonField = topP + @JsonProperty("topP") + @ExcludeMissing + fun _topP(): JsonField = topP @JsonProperty("use_cache") @ExcludeMissing @@ -3109,27 +3108,27 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleModelParams = apply { - if (validated) { - return@apply - } + fun validate(): GoogleModelParams = + apply { + if (validated) { + return@apply + } - maxOutputTokens() - temperature() - topK() - topP() - useCache() - validated = true - } + maxOutputTokens() + temperature() + topK() + topP() + useCache() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [GoogleModelParams]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [GoogleModelParams]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [GoogleModelParams]. */ @@ -3143,79 +3142,94 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleModelParams: GoogleModelParams) = apply { - maxOutputTokens = googleModelParams.maxOutputTokens - temperature = googleModelParams.temperature - topK = googleModelParams.topK - topP = googleModelParams.topP - useCache = googleModelParams.useCache - additionalProperties = googleModelParams.additionalProperties.toMutableMap() - } + internal fun from(googleModelParams: GoogleModelParams) = + apply { + maxOutputTokens = googleModelParams.maxOutputTokens + temperature = googleModelParams.temperature + topK = googleModelParams.topK + topP = googleModelParams.topP + useCache = googleModelParams.useCache + additionalProperties = googleModelParams.additionalProperties.toMutableMap() + } - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) - fun maxOutputTokens(maxOutputTokens: JsonField) = apply { - this.maxOutputTokens = maxOutputTokens - } + fun maxOutputTokens(maxOutputTokens: JsonField) = + apply { + this.maxOutputTokens = maxOutputTokens + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = + apply { + this.temperature = temperature + } fun topK(topK: Double) = topK(JsonField.of(topK)) - fun topK(topK: JsonField) = apply { this.topK = topK } + fun topK(topK: JsonField) = + apply { + this.topK = topK + } fun topP(topP: Double) = topP(JsonField.of(topP)) - fun topP(topP: JsonField) = apply { this.topP = topP } + fun topP(topP: JsonField) = + apply { + this.topP = topP + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GoogleModelParams = GoogleModelParams( - maxOutputTokens, - temperature, - topK, - topP, - useCache, - additionalProperties.toImmutable(), + maxOutputTokens, + temperature, + topK, + topP, + useCache, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GoogleModelParams && maxOutputTokens == other.maxOutputTokens && temperature == other.temperature && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GoogleModelParams && maxOutputTokens == other.maxOutputTokens && temperature == other.temperature && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3224,40 +3238,31 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "GoogleModelParams{maxOutputTokens=$maxOutputTokens, temperature=$temperature, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "GoogleModelParams{maxOutputTokens=$maxOutputTokens, temperature=$temperature, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class WindowAiModelParams - @JsonCreator - private constructor( - @JsonProperty("temperature") - @ExcludeMissing - private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("topK") - @ExcludeMissing - private val topK: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class WindowAiModelParams @JsonCreator private constructor( + @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("topK") @ExcludeMissing private val topK: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("temperature") @ExcludeMissing fun _temperature(): JsonField = temperature - @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK + @JsonProperty("topK") + @ExcludeMissing + fun _topK(): JsonField = topK @JsonProperty("use_cache") @ExcludeMissing @@ -3269,25 +3274,25 @@ private constructor( private var validated: Boolean = false - fun validate(): WindowAiModelParams = apply { - if (validated) { - return@apply - } + fun validate(): WindowAiModelParams = + apply { + if (validated) { + return@apply + } - temperature() - topK() - useCache() - validated = true - } + temperature() + topK() + useCache() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [WindowAiModelParams]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [WindowAiModelParams]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [WindowAiModelParams]. */ @@ -3299,64 +3304,76 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(windowAiModelParams: WindowAiModelParams) = apply { - temperature = windowAiModelParams.temperature - topK = windowAiModelParams.topK - useCache = windowAiModelParams.useCache - additionalProperties = windowAiModelParams.additionalProperties.toMutableMap() - } + internal fun from(windowAiModelParams: WindowAiModelParams) = + apply { + temperature = windowAiModelParams.temperature + topK = windowAiModelParams.topK + useCache = windowAiModelParams.useCache + additionalProperties = windowAiModelParams.additionalProperties.toMutableMap() + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = + apply { + this.temperature = temperature + } fun topK(topK: Double) = topK(JsonField.of(topK)) - fun topK(topK: JsonField) = apply { this.topK = topK } + fun topK(topK: JsonField) = + apply { + this.topK = topK + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): WindowAiModelParams = WindowAiModelParams( - temperature, - topK, - useCache, - additionalProperties.toImmutable(), + temperature, + topK, + useCache, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is WindowAiModelParams && temperature == other.temperature && topK == other.topK && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is WindowAiModelParams && temperature == other.temperature && topK == other.topK && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3365,23 +3382,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "WindowAiModelParams{temperature=$temperature, topK=$topK, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "WindowAiModelParams{temperature=$temperature, topK=$topK, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class JsCompletionParams - @JsonCreator - private constructor( - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class JsCompletionParams @JsonCreator private constructor( + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("use_cache") @ExcludeMissing @@ -3393,23 +3404,23 @@ private constructor( private var validated: Boolean = false - fun validate(): JsCompletionParams = apply { - if (validated) { - return@apply - } + fun validate(): JsCompletionParams = + apply { + if (validated) { + return@apply + } - useCache() - validated = true - } + useCache() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [JsCompletionParams]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [JsCompletionParams]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [JsCompletionParams]. */ @@ -3419,47 +3430,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jsCompletionParams: JsCompletionParams) = apply { - useCache = jsCompletionParams.useCache - additionalProperties = jsCompletionParams.additionalProperties.toMutableMap() - } + internal fun from(jsCompletionParams: JsCompletionParams) = + apply { + useCache = jsCompletionParams.useCache + additionalProperties = jsCompletionParams.additionalProperties.toMutableMap() + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): JsCompletionParams = - JsCompletionParams(useCache, additionalProperties.toImmutable()) + JsCompletionParams( + useCache, additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is JsCompletionParams && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsCompletionParams && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3468,17 +3489,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptOptions && model == other.model && params == other.params && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptOptions && model == other.model && params == other.params && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3487,6 +3507,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PromptOptions{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "PromptOptions{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index cf0797b3..fed28c24 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -25,14 +25,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will replace the existing prompt with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the + * same slug as the one specified in the request, will replace the existing prompt + * with the provided fields */ -class PromptReplaceParams -private constructor( +class PromptReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the prompt */ @@ -81,39 +82,24 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the prompt */ @@ -126,27 +112,30 @@ private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -163,7 +152,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -171,21 +162,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + slug() + description() + functionType() + promptData().ifPresent { it.validate() } + tags() + validated = true } - name() - projectId() - slug() - description() - functionType() - promptData().ifPresent { it.validate() } - tags() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -194,13 +186,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -216,34 +210,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionType = body.functionType - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionType = body.functionType + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -252,19 +256,19 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -273,9 +277,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -284,54 +289,70 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - description, - functionType, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + description, + functionType, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -340,8 +361,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -352,13 +372,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptReplaceParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptReplaceParams]. */ @@ -370,206 +392,286 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptReplaceParams: PromptReplaceParams) = apply { - body = promptReplaceParams.body.toBuilder() - additionalHeaders = promptReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = promptReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(promptReplaceParams: PromptReplaceParams) = + apply { + body = promptReplaceParams.body.toBuilder() + additionalHeaders = promptReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = promptReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the prompt */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { body.slug(slug) } + fun slug(slug: String) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + fun functionType(functionType: FunctionType?) = + apply { + body.functionType(functionType) + } - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = + apply { + body.functionType(functionType) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptReplaceParams = PromptReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -593,12 +695,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -607,17 +712,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -631,11 +737,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -649,23 +755,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -674,15 +777,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 039b2d8a..0889cb45 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a prompt object by its id */ -class PromptRetrieveParams -private constructor( +class PromptRetrieveParams private constructor( private val promptId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Prompt id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [PromptRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [PromptRetrieveParams]. * * The following fields are required: + * * ```java * .promptId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptRetrieveParams: PromptRetrieveParams) = apply { - promptId = promptRetrieveParams.promptId - additionalHeaders = promptRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = promptRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(promptRetrieveParams: PromptRetrieveParams) = + apply { + promptId = promptRetrieveParams.promptId + additionalHeaders = promptRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = promptRetrieveParams.additionalQueryParams.toBuilder() + } /** Prompt id */ - fun promptId(promptId: String) = apply { this.promptId = promptId } + fun promptId(promptId: String) = + apply { + this.promptId = promptId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptRetrieveParams = PromptRetrieveParams( - checkRequired("promptId", promptId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "promptId", promptId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptRetrieveParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptRetrieveParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index d8447483..abef1b23 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -23,16 +23,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a prompt object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class PromptUpdateParams -private constructor( +class PromptUpdateParams private constructor( private val promptId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Prompt id */ @@ -74,52 +74,39 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** Unique identifier for the prompt */ fun slug(): Optional = Optional.ofNullable(slug.getNullable("slug")) @@ -133,7 +120,9 @@ private constructor( fun _description(): JsonField = description /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -141,10 +130,14 @@ private constructor( fun _promptData(): JsonField = promptData /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -152,25 +145,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + description() + name() + promptData().ifPresent { it.validate() } + slug() + tags() + validated = true } - description() - name() - promptData().ifPresent { it.validate() } - slug() - tags() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -184,14 +179,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - description = body.description - name = body.name - promptData = body.promptData - slug = body.slug - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + description = body.description + name = body.name + promptData = body.promptData + slug = body.slug + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -200,9 +196,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -211,7 +208,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -220,9 +220,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** Unique identifier for the prompt */ fun slug(slug: String?) = slug(JsonField.ofNullable(slug)) @@ -231,7 +232,10 @@ private constructor( fun slug(slug: Optional) = slug(slug.getOrNull()) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -240,52 +244,62 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - description, - name, - promptData, - slug, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + description, + name, + promptData, + slug, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -294,8 +308,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -306,11 +319,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptUpdateParams]. * * The following fields are required: + * * ```java * .promptId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptUpdateParams]. */ @@ -323,200 +338,272 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptUpdateParams: PromptUpdateParams) = apply { - promptId = promptUpdateParams.promptId - body = promptUpdateParams.body.toBuilder() - additionalHeaders = promptUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = promptUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(promptUpdateParams: PromptUpdateParams) = + apply { + promptId = promptUpdateParams.promptId + body = promptUpdateParams.body.toBuilder() + additionalHeaders = promptUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = promptUpdateParams.additionalQueryParams.toBuilder() + } /** Prompt id */ - fun promptId(promptId: String) = apply { this.promptId = promptId } + fun promptId(promptId: String) = + apply { + this.promptId = promptId + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the prompt */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the prompt */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** Unique identifier for the prompt */ - fun slug(slug: String?) = apply { body.slug(slug) } + fun slug(slug: String?) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ fun slug(slug: Optional) = slug(slug.getOrNull()) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptUpdateParams = PromptUpdateParams( - checkRequired("promptId", promptId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "promptId", promptId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptUpdateParams{promptId=$promptId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptUpdateParams{promptId=$promptId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index a938b801..fda9c97a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -19,38 +19,22 @@ import kotlin.jvm.optionals.getOrNull /** Metadata about the state of the repo when the experiment was created */ @NoAutoDetect -class RepoInfo -@JsonCreator -private constructor( - @JsonProperty("author_email") - @ExcludeMissing - private val authorEmail: JsonField = JsonMissing.of(), - @JsonProperty("author_name") - @ExcludeMissing - private val authorName: JsonField = JsonMissing.of(), - @JsonProperty("branch") - @ExcludeMissing - private val branch: JsonField = JsonMissing.of(), - @JsonProperty("commit") - @ExcludeMissing - private val commit: JsonField = JsonMissing.of(), - @JsonProperty("commit_message") - @ExcludeMissing - private val commitMessage: JsonField = JsonMissing.of(), - @JsonProperty("commit_time") - @ExcludeMissing - private val commitTime: JsonField = JsonMissing.of(), +class RepoInfo @JsonCreator private constructor( + @JsonProperty("author_email") @ExcludeMissing private val authorEmail: JsonField = JsonMissing.of(), + @JsonProperty("author_name") @ExcludeMissing private val authorName: JsonField = JsonMissing.of(), + @JsonProperty("branch") @ExcludeMissing private val branch: JsonField = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing private val commit: JsonField = JsonMissing.of(), + @JsonProperty("commit_message") @ExcludeMissing private val commitMessage: JsonField = JsonMissing.of(), + @JsonProperty("commit_time") @ExcludeMissing private val commitTime: JsonField = JsonMissing.of(), @JsonProperty("dirty") @ExcludeMissing private val dirty: JsonField = JsonMissing.of(), - @JsonProperty("git_diff") - @ExcludeMissing - private val gitDiff: JsonField = JsonMissing.of(), + @JsonProperty("git_diff") @ExcludeMissing private val gitDiff: JsonField = JsonMissing.of(), @JsonProperty("tag") @ExcludeMissing private val tag: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Email of the author of the most recent commit */ - fun authorEmail(): Optional = - Optional.ofNullable(authorEmail.getNullable("author_email")) + fun authorEmail(): Optional = Optional.ofNullable(authorEmail.getNullable("author_email")) /** Name of the author of the most recent commit */ fun authorName(): Optional = Optional.ofNullable(authorName.getNullable("author_name")) @@ -62,8 +46,7 @@ private constructor( fun commit(): Optional = Optional.ofNullable(commit.getNullable("commit")) /** Most recent commit message */ - fun commitMessage(): Optional = - Optional.ofNullable(commitMessage.getNullable("commit_message")) + fun commitMessage(): Optional = Optional.ofNullable(commitMessage.getNullable("commit_message")) /** Time of the most recent commit */ fun commitTime(): Optional = Optional.ofNullable(commitTime.getNullable("commit_time")) @@ -72,8 +55,8 @@ private constructor( fun dirty(): Optional = Optional.ofNullable(dirty.getNullable("dirty")) /** - * If the repo was dirty when run, this includes the diff between the current state of the repo - * and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ fun gitDiff(): Optional = Optional.ofNullable(gitDiff.getNullable("git_diff")) @@ -86,13 +69,19 @@ private constructor( fun _authorEmail(): JsonField = authorEmail /** Name of the author of the most recent commit */ - @JsonProperty("author_name") @ExcludeMissing fun _authorName(): JsonField = authorName + @JsonProperty("author_name") + @ExcludeMissing + fun _authorName(): JsonField = authorName /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + @JsonProperty("branch") + @ExcludeMissing + fun _branch(): JsonField = branch /** SHA of most recent commit */ - @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + @JsonProperty("commit") + @ExcludeMissing + fun _commit(): JsonField = commit /** Most recent commit message */ @JsonProperty("commit_message") @@ -100,19 +89,27 @@ private constructor( fun _commitMessage(): JsonField = commitMessage /** Time of the most recent commit */ - @JsonProperty("commit_time") @ExcludeMissing fun _commitTime(): JsonField = commitTime + @JsonProperty("commit_time") + @ExcludeMissing + fun _commitTime(): JsonField = commitTime /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") @ExcludeMissing fun _dirty(): JsonField = dirty + @JsonProperty("dirty") + @ExcludeMissing + fun _dirty(): JsonField = dirty /** - * If the repo was dirty when run, this includes the diff between the current state of the repo - * and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ - @JsonProperty("git_diff") @ExcludeMissing fun _gitDiff(): JsonField = gitDiff + @JsonProperty("git_diff") + @ExcludeMissing + fun _gitDiff(): JsonField = gitDiff /** Name of the tag on the most recent commit */ - @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField = tag + @JsonProperty("tag") + @ExcludeMissing + fun _tag(): JsonField = tag @JsonAnyGetter @ExcludeMissing @@ -120,29 +117,31 @@ private constructor( private var validated: Boolean = false - fun validate(): RepoInfo = apply { - if (validated) { - return@apply + fun validate(): RepoInfo = + apply { + if (validated) { + return@apply + } + + authorEmail() + authorName() + branch() + commit() + commitMessage() + commitTime() + dirty() + gitDiff() + tag() + validated = true } - authorEmail() - authorName() - branch() - commit() - commitMessage() - commitTime() - dirty() - gitDiff() - tag() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [RepoInfo]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RepoInfo]. */ @@ -160,18 +159,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(repoInfo: RepoInfo) = apply { - authorEmail = repoInfo.authorEmail - authorName = repoInfo.authorName - branch = repoInfo.branch - commit = repoInfo.commit - commitMessage = repoInfo.commitMessage - commitTime = repoInfo.commitTime - dirty = repoInfo.dirty - gitDiff = repoInfo.gitDiff - tag = repoInfo.tag - additionalProperties = repoInfo.additionalProperties.toMutableMap() - } + internal fun from(repoInfo: RepoInfo) = + apply { + authorEmail = repoInfo.authorEmail + authorName = repoInfo.authorName + branch = repoInfo.branch + commit = repoInfo.commit + commitMessage = repoInfo.commitMessage + commitTime = repoInfo.commitTime + dirty = repoInfo.dirty + gitDiff = repoInfo.gitDiff + tag = repoInfo.tag + additionalProperties = repoInfo.additionalProperties.toMutableMap() + } /** Email of the author of the most recent commit */ fun authorEmail(authorEmail: String?) = authorEmail(JsonField.ofNullable(authorEmail)) @@ -180,7 +180,10 @@ private constructor( fun authorEmail(authorEmail: Optional) = authorEmail(authorEmail.getOrNull()) /** Email of the author of the most recent commit */ - fun authorEmail(authorEmail: JsonField) = apply { this.authorEmail = authorEmail } + fun authorEmail(authorEmail: JsonField) = + apply { + this.authorEmail = authorEmail + } /** Name of the author of the most recent commit */ fun authorName(authorName: String?) = authorName(JsonField.ofNullable(authorName)) @@ -189,7 +192,10 @@ private constructor( fun authorName(authorName: Optional) = authorName(authorName.getOrNull()) /** Name of the author of the most recent commit */ - fun authorName(authorName: JsonField) = apply { this.authorName = authorName } + fun authorName(authorName: JsonField) = + apply { + this.authorName = authorName + } /** Name of the branch the most recent commit belongs to */ fun branch(branch: String?) = branch(JsonField.ofNullable(branch)) @@ -198,7 +204,10 @@ private constructor( fun branch(branch: Optional) = branch(branch.getOrNull()) /** Name of the branch the most recent commit belongs to */ - fun branch(branch: JsonField) = apply { this.branch = branch } + fun branch(branch: JsonField) = + apply { + this.branch = branch + } /** SHA of most recent commit */ fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) @@ -207,20 +216,22 @@ private constructor( fun commit(commit: Optional) = commit(commit.getOrNull()) /** SHA of most recent commit */ - fun commit(commit: JsonField) = apply { this.commit = commit } + fun commit(commit: JsonField) = + apply { + this.commit = commit + } /** Most recent commit message */ - fun commitMessage(commitMessage: String?) = - commitMessage(JsonField.ofNullable(commitMessage)) + fun commitMessage(commitMessage: String?) = commitMessage(JsonField.ofNullable(commitMessage)) /** Most recent commit message */ - fun commitMessage(commitMessage: Optional) = - commitMessage(commitMessage.getOrNull()) + fun commitMessage(commitMessage: Optional) = commitMessage(commitMessage.getOrNull()) /** Most recent commit message */ - fun commitMessage(commitMessage: JsonField) = apply { - this.commitMessage = commitMessage - } + fun commitMessage(commitMessage: JsonField) = + apply { + this.commitMessage = commitMessage + } /** Time of the most recent commit */ fun commitTime(commitTime: String?) = commitTime(JsonField.ofNullable(commitTime)) @@ -229,7 +240,10 @@ private constructor( fun commitTime(commitTime: Optional) = commitTime(commitTime.getOrNull()) /** Time of the most recent commit */ - fun commitTime(commitTime: JsonField) = apply { this.commitTime = commitTime } + fun commitTime(commitTime: JsonField) = + apply { + this.commitTime = commitTime + } /** Whether or not the repo had uncommitted changes when snapshotted */ fun dirty(dirty: Boolean?) = dirty(JsonField.ofNullable(dirty)) @@ -241,25 +255,31 @@ private constructor( fun dirty(dirty: Optional) = dirty(dirty.getOrNull()) /** Whether or not the repo had uncommitted changes when snapshotted */ - fun dirty(dirty: JsonField) = apply { this.dirty = dirty } + fun dirty(dirty: JsonField) = + apply { + this.dirty = dirty + } /** - * If the repo was dirty when run, this includes the diff between the current state of the - * repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ fun gitDiff(gitDiff: String?) = gitDiff(JsonField.ofNullable(gitDiff)) /** - * If the repo was dirty when run, this includes the diff between the current state of the - * repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ fun gitDiff(gitDiff: Optional) = gitDiff(gitDiff.getOrNull()) /** - * If the repo was dirty when run, this includes the diff between the current state of the - * repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ - fun gitDiff(gitDiff: JsonField) = apply { this.gitDiff = gitDiff } + fun gitDiff(gitDiff: JsonField) = + apply { + this.gitDiff = gitDiff + } /** Name of the tag on the most recent commit */ fun tag(tag: String?) = tag(JsonField.ofNullable(tag)) @@ -268,48 +288,58 @@ private constructor( fun tag(tag: Optional) = tag(tag.getOrNull()) /** Name of the tag on the most recent commit */ - fun tag(tag: JsonField) = apply { this.tag = tag } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun tag(tag: JsonField) = + apply { + this.tag = tag + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RepoInfo = RepoInfo( - authorEmail, - authorName, - branch, - commit, - commitMessage, - commitTime, - dirty, - gitDiff, - tag, - additionalProperties.toImmutable(), + authorEmail, + authorName, + branch, + commit, + commitMessage, + commitTime, + dirty, + gitDiff, + tag, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RepoInfo && authorEmail == other.authorEmail && authorName == other.authorName && branch == other.branch && commit == other.commit && commitMessage == other.commitMessage && commitTime == other.commitTime && dirty == other.dirty && gitDiff == other.gitDiff && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RepoInfo && authorEmail == other.authorEmail && authorName == other.authorName && branch == other.branch && commit == other.commit && commitMessage == other.commitMessage && commitTime == other.commitTime && dirty == other.dirty && gitDiff == other.gitDiff && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -318,6 +348,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RepoInfo{authorEmail=$authorEmail, authorName=$authorName, branch=$branch, commit=$commit, commitMessage=$commitMessage, commitTime=$commitTime, dirty=$dirty, gitDiff=$gitDiff, tag=$tag, additionalProperties=$additionalProperties}" + override fun toString() = "RepoInfo{authorEmail=$authorEmail, authorName=$authorName, branch=$branch, commit=$commit, commitMessage=$commitMessage, commitTime=$commitTime, dirty=$dirty, gitDiff=$gitDiff, tag=$tag, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt index 3af60e1a..af3cc656 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt @@ -25,34 +25,22 @@ import kotlin.jvm.optionals.getOrNull /** * A role is a collection of permissions which can be granted as part of an ACL * - * Roles can consist of individual permissions, as well as a set of roles they inherit from + * Roles can consist of individual permissions, as well as a set of roles they + * inherit from */ @NoAutoDetect -class Role -@JsonCreator -private constructor( +class Role @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_permissions") - @ExcludeMissing - private val memberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("member_roles") - @ExcludeMissing - private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") @ExcludeMissing private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") @ExcludeMissing private val memberRoles: JsonField> = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the role */ @@ -65,31 +53,27 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the role */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = - Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(): Optional> = - Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by any - * other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -99,13 +83,19 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the role */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Date of role creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -113,7 +103,9 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the role */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -123,8 +115,8 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing @@ -133,15 +125,19 @@ private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by any - * other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Identifies the user who created the role */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -149,22 +145,23 @@ private constructor( private var validated: Boolean = false - fun validate(): Role = apply { - if (validated) { - return@apply - } + fun validate(): Role = + apply { + if (validated) { + return@apply + } - id() - name() - created() - deletedAt() - description() - memberPermissions().ifPresent { it.forEach { it.validate() } } - memberRoles() - orgId() - userId() - validated = true - } + id() + name() + created() + deletedAt() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgId() + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -174,12 +171,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Role]. * * The following fields are required: + * * ```java * .id() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Role]. */ @@ -197,30 +196,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(role: Role) = apply { - id = role.id - name = role.name - created = role.created - deletedAt = role.deletedAt - description = role.description - memberPermissions = role.memberPermissions.map { it.toMutableList() } - memberRoles = role.memberRoles.map { it.toMutableList() } - orgId = role.orgId - userId = role.userId - additionalProperties = role.additionalProperties.toMutableMap() - } + internal fun from(role: Role) = + apply { + id = role.id + name = role.name + created = role.created + deletedAt = role.deletedAt + description = role.description + memberPermissions = role.memberPermissions.map { it.toMutableList() } + memberRoles = role.memberRoles.map { it.toMutableList() } + orgId = role.orgId + userId = role.userId + additionalProperties = role.additionalProperties.toMutableMap() + } /** Unique identifier for the role */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the role */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) /** Name of the role */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Date of role creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -229,7 +235,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of role creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -238,7 +247,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -247,73 +259,76 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = - memberPermissions(JsonField.ofNullable(memberPermissions)) + fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - this.memberPermissions = memberPermissions.map { it.toMutableList() } - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - memberPermissions = - (memberPermissions ?: JsonField.of(mutableListOf())).also { + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("memberPermissions", it).add(memberPermission) } - } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - this.memberRoles = memberRoles.map { it.toMutableList() } - } + fun memberRoles(memberRoles: JsonField>) = + apply { + this.memberRoles = memberRoles.map { it.toMutableList() } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { - memberRoles = - (memberRoles ?: JsonField.of(mutableListOf())).also { + fun addMemberRole(memberRole: String) = + apply { + memberRoles = (memberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("memberRoles", it).add(memberRole) } - } + } /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -322,8 +337,8 @@ private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -332,12 +347,15 @@ private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Identifies the user who created the role */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -346,71 +364,80 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the role */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Role = Role( - checkRequired("id", id), - checkRequired("name", name), - created, - deletedAt, - description, - (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - orgId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + created, + deletedAt, + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgId, + userId, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class MemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class MemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -427,15 +454,16 @@ private constructor( private var validated: Boolean = false - fun validate(): MemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): MemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -445,11 +473,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [MemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [MemberPermission]. */ @@ -460,87 +490,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(memberPermission: MemberPermission) = apply { - permission = memberPermission.permission - restrictObjectType = memberPermission.restrictObjectType - additionalProperties = memberPermission.additionalProperties.toMutableMap() - } + internal fun from(memberPermission: MemberPermission) = + apply { + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() + } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MemberPermission = MemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - class Permission @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -579,9 +623,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -604,8 +650,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -627,7 +673,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -648,20 +694,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -670,19 +713,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -732,9 +777,11 @@ private constructor( * * An instance of [RestrictObjectType] can contain an unknown value in a couple of * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -760,8 +807,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -786,7 +833,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -801,8 +848,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -811,20 +857,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -833,11 +876,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -846,16 +889,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && id == other.id && name == other.name && created == other.created && deletedAt == other.deletedAt && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Role && id == other.id && name == other.name && created == other.created && deletedAt == other.deletedAt && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -864,6 +906,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Role{id=$id, name=$name, created=$created, deletedAt=$deletedAt, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Role{id=$id, name=$name, created=$created, deletedAt=$deletedAt, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt index 9e08f6e4..8125aad3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt @@ -25,14 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new role. If there is an existing role with the same name as the one specified in the - * request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one + * specified in the request, will return the existing role unmodified */ -class RoleCreateParams -private constructor( +class RoleCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the role */ @@ -47,15 +47,15 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(): Optional> = body.memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(): Optional = body.orgName() @@ -71,15 +71,15 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun _memberRoles(): JsonField> = body._memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -89,64 +89,52 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_permissions") - @ExcludeMissing - private val memberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("member_roles") - @ExcludeMissing - private val memberRoles: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") @ExcludeMissing private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") @ExcludeMissing private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the role */ fun name(): String = name.getRequired("name") /** Textual description of the role */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = - Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(): Optional> = - Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Textual description of the role */ @JsonProperty("description") @@ -161,19 +149,21 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles(): JsonField> = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -181,18 +171,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - description() - memberPermissions().ifPresent { it.forEach { it.validate() } } - memberRoles() - orgName() - validated = true - } + name() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -202,11 +193,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -220,20 +213,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - description = body.description - memberPermissions = body.memberPermissions.map { it.toMutableList() } - memberRoles = body.memberRoles.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + description = body.description + memberPermissions = body.memberPermissions.map { it.toMutableList() } + memberRoles = body.memberRoles.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) /** Name of the role */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -242,129 +239,140 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = - memberPermissions(JsonField.ofNullable(memberPermissions)) + fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - this.memberPermissions = memberPermissions.map { it.toMutableList() } - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - memberPermissions = - (memberPermissions ?: JsonField.of(mutableListOf())).also { + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("memberPermissions", it).add(memberPermission) } - } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = - memberRoles(JsonField.ofNullable(memberRoles)) + fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: Optional>) = - memberRoles(memberRoles.getOrNull()) + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - this.memberRoles = memberRoles.map { it.toMutableList() } - } + fun memberRoles(memberRoles: JsonField>) = + apply { + this.memberRoles = memberRoles.map { it.toMutableList() } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { - memberRoles = - (memberRoles ?: JsonField.of(mutableListOf())).also { + fun addMemberRole(memberRole: String) = + apply { + memberRoles = (memberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("memberRoles", it).add(memberRole) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - description, - (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -373,8 +381,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -385,11 +392,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleCreateParams]. */ @@ -401,251 +410,312 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleCreateParams: RoleCreateParams) = apply { - body = roleCreateParams.body.toBuilder() - additionalHeaders = roleCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = roleCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(roleCreateParams: RoleCreateParams) = + apply { + body = roleCreateParams.body.toBuilder() + additionalHeaders = roleCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleCreateParams.additionalQueryParams.toBuilder() + } /** Name of the role */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the role */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Textual description of the role */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the role */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: List?) = + apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - body.addMemberPermission(memberPermission) - } + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + body.addMemberPermission(memberPermission) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } + fun memberRoles(memberRoles: List?) = + apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - body.memberRoles(memberRoles) - } + fun memberRoles(memberRoles: JsonField>) = + apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } + fun addMemberRole(memberRole: String) = + apply { + body.addMemberRole(memberRole) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleCreateParams = - RoleCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + RoleCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) } @NoAutoDetect - class MemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class MemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -662,15 +732,16 @@ private constructor( private var validated: Boolean = false - fun validate(): MemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): MemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -680,11 +751,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [MemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [MemberPermission]. */ @@ -695,87 +768,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(memberPermission: MemberPermission) = apply { - permission = memberPermission.permission - restrictObjectType = memberPermission.restrictObjectType - additionalProperties = memberPermission.additionalProperties.toMutableMap() - } + internal fun from(memberPermission: MemberPermission) = + apply { + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() + } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MemberPermission = MemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - class Permission @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -814,9 +901,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -839,8 +928,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -862,7 +951,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -883,20 +972,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -905,19 +991,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -967,9 +1055,11 @@ private constructor( * * An instance of [RestrictObjectType] can contain an unknown value in a couple of * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -995,8 +1085,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1021,7 +1111,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1036,8 +1126,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1046,20 +1135,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1068,11 +1154,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1081,20 +1167,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 1eae7094..5e64142f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a role object by its id */ -class RoleDeleteParams -private constructor( +class RoleDeleteParams private constructor( private val roleId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Role id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleDeleteParams]. * * The following fields are required: + * * ```java * .roleId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(roleDeleteParams: RoleDeleteParams) = apply { - roleId = roleDeleteParams.roleId - additionalHeaders = roleDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = roleDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = roleDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(roleDeleteParams: RoleDeleteParams) = + apply { + roleId = roleDeleteParams.roleId + additionalHeaders = roleDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = roleDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = roleDeleteParams.additionalBodyProperties.toMutableMap() + } /** Role id */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String) = + apply { + this.roleId = roleId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): RoleDeleteParams = RoleDeleteParams( - checkRequired("roleId", roleId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "roleId", roleId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleDeleteParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleDeleteParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index f0957758..12783198 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.RoleService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all roles. The roles are sorted by creation date, with the most recently-created roles - * coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ -class RoleListPage -private constructor( +class RoleListPage private constructor( private val rolesService: RoleService, private val params: RoleListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleListPage && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is RoleListPage && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ - override fun toString() = - "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" + override fun toString() = "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(RoleListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(RoleListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { rolesService.list(it) } + return getNextPageParams().map { rolesService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(rolesService: RoleService, params: RoleListParams, response: Response) = - RoleListPage(rolesService, params, response) + RoleListPage( + rolesService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [RoleListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: RoleListPage) : Iterable { + class AutoPager( + private val firstPage: RoleListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index baef96f9..a227e991 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.RoleServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all roles. The roles are sorted by creation date, with the most recently-created roles - * coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ -class RoleListPageAsync -private constructor( +class RoleListPageAsync private constructor( private val rolesService: RoleServiceAsync, private val params: RoleListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleListPageAsync && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is RoleListPageAsync && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ - override fun toString() = - "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" + override fun toString() = "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(RoleListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(RoleListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { rolesService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + rolesService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(rolesService: RoleServiceAsync, params: RoleListParams, response: Response) = - RoleListPageAsync(rolesService, params, response) + RoleListPageAsync( + rolesService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [RoleListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: RoleListPageAsync) { + class AutoPager( + private val firstPage: RoleListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Role) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Role) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index df21940e..870fb484 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all roles. The roles are sorted by creation date, with the most recently-created roles - * coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ -class RoleListParams -private constructor( +class RoleListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -36,20 +35,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,51 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.roleName?.let { queryParams.put("role_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.roleName?.let { + queryParams.put( + "role_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): RoleListParams = builder().build() + @JvmStatic + fun none(): RoleListParams = builder().build() /** Returns a mutable builder for constructing an instance of [RoleListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleListParams]. */ @@ -113,61 +139,71 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleListParams: RoleListParams) = apply { - endingBefore = roleListParams.endingBefore - ids = roleListParams.ids - limit = roleListParams.limit - orgName = roleListParams.orgName - roleName = roleListParams.roleName - startingAfter = roleListParams.startingAfter - additionalHeaders = roleListParams.additionalHeaders.toBuilder() - additionalQueryParams = roleListParams.additionalQueryParams.toBuilder() - } + internal fun from(roleListParams: RoleListParams) = + apply { + endingBefore = roleListParams.endingBefore + ids = roleListParams.ids + limit = roleListParams.limit + orgName = roleListParams.orgName + roleName = roleListParams.roleName + startingAfter = roleListParams.startingAfter + additionalHeaders = roleListParams.additionalHeaders.toBuilder() + additionalQueryParams = roleListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -176,13 +212,19 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the role to search for */ - fun roleName(roleName: String?) = apply { this.roleName = roleName } + fun roleName(roleName: String?) = + apply { + this.roleName = roleName + } /** Name of the role to search for */ fun roleName(roleName: Optional) = roleName(roleName.getOrNull()) @@ -190,144 +232,172 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleListParams = RoleListParams( - endingBefore, - ids, - limit, - orgName, - roleName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + roleName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -345,19 +415,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -372,12 +442,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -387,60 +462,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && roleName == other.roleName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && roleName == other.roleName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt index 8b9e78ad..004b08b7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt @@ -25,14 +25,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace role. If there is an existing role with the same name as the one specified in - * the request, will replace the existing role with the provided fields + * Create or replace role. If there is an existing role with the same name as the + * one specified in the request, will replace the existing role with the provided + * fields */ -class RoleReplaceParams -private constructor( +class RoleReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the role */ @@ -47,15 +48,15 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(): Optional> = body.memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(): Optional = body.orgName() @@ -71,15 +72,15 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun _memberRoles(): JsonField> = body._memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -89,64 +90,52 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_permissions") - @ExcludeMissing - private val memberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("member_roles") - @ExcludeMissing - private val memberRoles: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") @ExcludeMissing private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") @ExcludeMissing private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the role */ fun name(): String = name.getRequired("name") /** Textual description of the role */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = - Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(): Optional> = - Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Textual description of the role */ @JsonProperty("description") @@ -161,19 +150,21 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles(): JsonField> = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -181,18 +172,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - description() - memberPermissions().ifPresent { it.forEach { it.validate() } } - memberRoles() - orgName() - validated = true - } + name() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -202,11 +194,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -220,20 +214,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - description = body.description - memberPermissions = body.memberPermissions.map { it.toMutableList() } - memberRoles = body.memberRoles.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + description = body.description + memberPermissions = body.memberPermissions.map { it.toMutableList() } + memberRoles = body.memberRoles.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) /** Name of the role */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -242,129 +240,140 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = - memberPermissions(JsonField.ofNullable(memberPermissions)) + fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - this.memberPermissions = memberPermissions.map { it.toMutableList() } - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - memberPermissions = - (memberPermissions ?: JsonField.of(mutableListOf())).also { + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("memberPermissions", it).add(memberPermission) } - } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = - memberRoles(JsonField.ofNullable(memberRoles)) + fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: Optional>) = - memberRoles(memberRoles.getOrNull()) + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - this.memberRoles = memberRoles.map { it.toMutableList() } - } + fun memberRoles(memberRoles: JsonField>) = + apply { + this.memberRoles = memberRoles.map { it.toMutableList() } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { - memberRoles = - (memberRoles ?: JsonField.of(mutableListOf())).also { + fun addMemberRole(memberRole: String) = + apply { + memberRoles = (memberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("memberRoles", it).add(memberRole) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - description, - (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -373,8 +382,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -385,11 +393,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleReplaceParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleReplaceParams]. */ @@ -401,255 +411,312 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleReplaceParams: RoleReplaceParams) = apply { - body = roleReplaceParams.body.toBuilder() - additionalHeaders = roleReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = roleReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(roleReplaceParams: RoleReplaceParams) = + apply { + body = roleReplaceParams.body.toBuilder() + additionalHeaders = roleReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = roleReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the role */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the role */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Textual description of the role */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the role */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: List?) = + apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - body.addMemberPermission(memberPermission) - } + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + body.addMemberPermission(memberPermission) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } + fun memberRoles(memberRoles: List?) = + apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - body.memberRoles(memberRoles) - } + fun memberRoles(memberRoles: JsonField>) = + apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } + fun addMemberRole(memberRole: String) = + apply { + body.addMemberRole(memberRole) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleReplaceParams = RoleReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class MemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class MemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -666,15 +733,16 @@ private constructor( private var validated: Boolean = false - fun validate(): MemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): MemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -684,11 +752,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [MemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [MemberPermission]. */ @@ -699,87 +769,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(memberPermission: MemberPermission) = apply { - permission = memberPermission.permission - restrictObjectType = memberPermission.restrictObjectType - additionalProperties = memberPermission.additionalProperties.toMutableMap() - } + internal fun from(memberPermission: MemberPermission) = + apply { + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() + } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MemberPermission = MemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - class Permission @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -818,9 +902,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -843,8 +929,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -866,7 +952,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -887,20 +973,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -909,19 +992,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -971,9 +1056,11 @@ private constructor( * * An instance of [RestrictObjectType] can contain an unknown value in a couple of * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -999,8 +1086,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1025,7 +1112,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1040,8 +1127,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1050,20 +1136,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1072,11 +1155,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1085,20 +1168,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 70a23fdd..1bb0b88f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a role object by its id */ -class RoleRetrieveParams -private constructor( +class RoleRetrieveParams private constructor( private val roleId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Role id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,11 +43,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleRetrieveParams]. * * The following fields are required: + * * ```java * .roleId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleRetrieveParams]. */ @@ -59,131 +61,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleRetrieveParams: RoleRetrieveParams) = apply { - roleId = roleRetrieveParams.roleId - additionalHeaders = roleRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = roleRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(roleRetrieveParams: RoleRetrieveParams) = + apply { + roleId = roleRetrieveParams.roleId + additionalHeaders = roleRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = roleRetrieveParams.additionalQueryParams.toBuilder() + } /** Role id */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String) = + apply { + this.roleId = roleId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleRetrieveParams = RoleRetrieveParams( - checkRequired("roleId", roleId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "roleId", roleId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleRetrieveParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleRetrieveParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt index ac99a23e..b6b26ea8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt @@ -25,16 +25,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ -class RoleUpdateParams -private constructor( +class RoleUpdateParams private constructor( private val roleId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Role id */ @@ -53,8 +53,7 @@ private constructor( fun name(): Optional = body.name() /** A list of permissions to remove from the role */ - fun removeMemberPermissions(): Optional> = - body.removeMemberPermissions() + fun removeMemberPermissions(): Optional> = body.removeMemberPermissions() /** A list of role IDs to remove from the role's inheriting-from set */ fun removeMemberRoles(): Optional> = body.removeMemberRoles() @@ -72,8 +71,7 @@ private constructor( fun _name(): JsonField = body._name() /** A list of permissions to remove from the role */ - fun _removeMemberPermissions(): JsonField> = - body._removeMemberPermissions() + fun _removeMemberPermissions(): JsonField> = body._removeMemberPermissions() /** A list of role IDs to remove from the role's inheriting-from set */ fun _removeMemberRoles(): JsonField> = body._removeMemberRoles() @@ -84,68 +82,49 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("add_member_permissions") - @ExcludeMissing - private val addMemberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("add_member_roles") - @ExcludeMissing - private val addMemberRoles: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("remove_member_permissions") - @ExcludeMissing - private val removeMemberPermissions: JsonField> = - JsonMissing.of(), - @JsonProperty("remove_member_roles") - @ExcludeMissing - private val removeMemberRoles: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("add_member_permissions") @ExcludeMissing private val addMemberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("add_member_roles") @ExcludeMissing private val addMemberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("remove_member_permissions") @ExcludeMissing private val removeMemberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("remove_member_roles") @ExcludeMissing private val removeMemberRoles: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of permissions to add to the role */ - fun addMemberPermissions(): Optional> = - Optional.ofNullable(addMemberPermissions.getNullable("add_member_permissions")) + fun addMemberPermissions(): Optional> = Optional.ofNullable(addMemberPermissions.getNullable("add_member_permissions")) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(): Optional> = - Optional.ofNullable(addMemberRoles.getNullable("add_member_roles")) + fun addMemberRoles(): Optional> = Optional.ofNullable(addMemberRoles.getNullable("add_member_roles")) /** Textual description of the role */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the role */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** A list of permissions to remove from the role */ - fun removeMemberPermissions(): Optional> = - Optional.ofNullable(removeMemberPermissions.getNullable("remove_member_permissions")) + fun removeMemberPermissions(): Optional> = Optional.ofNullable(removeMemberPermissions.getNullable("remove_member_permissions")) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(): Optional> = - Optional.ofNullable(removeMemberRoles.getNullable("remove_member_roles")) + fun removeMemberRoles(): Optional> = Optional.ofNullable(removeMemberRoles.getNullable("remove_member_roles")) /** A list of permissions to add to the role */ @JsonProperty("add_member_permissions") @@ -163,13 +142,14 @@ private constructor( fun _description(): JsonField = description /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** A list of permissions to remove from the role */ @JsonProperty("remove_member_permissions") @ExcludeMissing - fun _removeMemberPermissions(): JsonField> = - removeMemberPermissions + fun _removeMemberPermissions(): JsonField> = removeMemberPermissions /** A list of role IDs to remove from the role's inheriting-from set */ @JsonProperty("remove_member_roles") @@ -182,26 +162,28 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - addMemberPermissions().ifPresent { it.forEach { it.validate() } } - addMemberRoles() - description() - name() - removeMemberPermissions().ifPresent { it.forEach { it.validate() } } - removeMemberRoles() - validated = true - } + addMemberPermissions().ifPresent { it.forEach { it.validate() } } + addMemberRoles() + description() + name() + removeMemberPermissions().ifPresent { it.forEach { it.validate() } } + removeMemberRoles() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -211,29 +193,27 @@ private constructor( private var addMemberRoles: JsonField>? = null private var description: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var removeMemberPermissions: JsonField>? = - null + private var removeMemberPermissions: JsonField>? = null private var removeMemberRoles: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - addMemberPermissions = body.addMemberPermissions.map { it.toMutableList() } - addMemberRoles = body.addMemberRoles.map { it.toMutableList() } - description = body.description - name = body.name - removeMemberPermissions = body.removeMemberPermissions.map { it.toMutableList() } - removeMemberRoles = body.removeMemberRoles.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + addMemberPermissions = body.addMemberPermissions.map { it.toMutableList() } + addMemberRoles = body.addMemberRoles.map { it.toMutableList() } + description = body.description + name = body.name + removeMemberPermissions = body.removeMemberPermissions.map { it.toMutableList() } + removeMemberRoles = body.removeMemberRoles.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: List?) = - addMemberPermissions(JsonField.ofNullable(addMemberPermissions)) + fun addMemberPermissions(addMemberPermissions: List?) = addMemberPermissions(JsonField.ofNullable(addMemberPermissions)) /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: Optional>) = - addMemberPermissions(addMemberPermissions.getOrNull()) + fun addMemberPermissions(addMemberPermissions: Optional>) = addMemberPermissions(addMemberPermissions.getOrNull()) /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: JsonField>) = @@ -242,33 +222,32 @@ private constructor( } /** A list of permissions to add to the role */ - fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { - addMemberPermissions = - (addMemberPermissions ?: JsonField.of(mutableListOf())).also { + fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = + apply { + addMemberPermissions = (addMemberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberPermissions", it).add(addMemberPermission) } - } + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: List?) = - addMemberRoles(JsonField.ofNullable(addMemberRoles)) + fun addMemberRoles(addMemberRoles: List?) = addMemberRoles(JsonField.ofNullable(addMemberRoles)) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: Optional>) = - addMemberRoles(addMemberRoles.getOrNull()) + fun addMemberRoles(addMemberRoles: Optional>) = addMemberRoles(addMemberRoles.getOrNull()) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: JsonField>) = apply { - this.addMemberRoles = addMemberRoles.map { it.toMutableList() } - } + fun addMemberRoles(addMemberRoles: JsonField>) = + apply { + this.addMemberRoles = addMemberRoles.map { it.toMutableList() } + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addAddMemberRole(addMemberRole: String) = apply { - addMemberRoles = - (addMemberRoles ?: JsonField.of(mutableListOf())).also { + fun addAddMemberRole(addMemberRole: String) = + apply { + addMemberRoles = (addMemberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberRoles", it).add(addMemberRole) } - } + } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -277,9 +256,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the role */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -288,90 +268,95 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the role */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** A list of permissions to remove from the role */ - fun removeMemberPermissions(removeMemberPermissions: List?) = - removeMemberPermissions(JsonField.ofNullable(removeMemberPermissions)) + fun removeMemberPermissions(removeMemberPermissions: List?) = removeMemberPermissions(JsonField.ofNullable(removeMemberPermissions)) /** A list of permissions to remove from the role */ - fun removeMemberPermissions( - removeMemberPermissions: Optional> - ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) + fun removeMemberPermissions(removeMemberPermissions: Optional>) = removeMemberPermissions(removeMemberPermissions.getOrNull()) /** A list of permissions to remove from the role */ - fun removeMemberPermissions( - removeMemberPermissions: JsonField> - ) = apply { - this.removeMemberPermissions = removeMemberPermissions.map { it.toMutableList() } - } + fun removeMemberPermissions(removeMemberPermissions: JsonField>) = + apply { + this.removeMemberPermissions = removeMemberPermissions.map { it.toMutableList() } + } /** A list of permissions to remove from the role */ - fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { - removeMemberPermissions = - (removeMemberPermissions ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = + apply { + removeMemberPermissions = (removeMemberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberPermissions", it).add(removeMemberPermission) } - } + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: List?) = - removeMemberRoles(JsonField.ofNullable(removeMemberRoles)) + fun removeMemberRoles(removeMemberRoles: List?) = removeMemberRoles(JsonField.ofNullable(removeMemberRoles)) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: Optional>) = - removeMemberRoles(removeMemberRoles.getOrNull()) + fun removeMemberRoles(removeMemberRoles: Optional>) = removeMemberRoles(removeMemberRoles.getOrNull()) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { - this.removeMemberRoles = removeMemberRoles.map { it.toMutableList() } - } + fun removeMemberRoles(removeMemberRoles: JsonField>) = + apply { + this.removeMemberRoles = removeMemberRoles.map { it.toMutableList() } + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun addRemoveMemberRole(removeMemberRole: String) = apply { - removeMemberRoles = - (removeMemberRoles ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberRole(removeMemberRole: String) = + apply { + removeMemberRoles = (removeMemberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberRoles", it).add(removeMemberRole) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - (addMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (addMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - description, - name, - (removeMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (removeMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (addMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (addMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + description, + name, + (removeMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (removeMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -380,8 +365,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" + override fun toString() = "Body{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -392,11 +376,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleUpdateParams]. * * The following fields are required: + * * ```java * .roleId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleUpdateParams]. */ @@ -409,24 +395,28 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleUpdateParams: RoleUpdateParams) = apply { - roleId = roleUpdateParams.roleId - body = roleUpdateParams.body.toBuilder() - additionalHeaders = roleUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = roleUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(roleUpdateParams: RoleUpdateParams) = + apply { + roleId = roleUpdateParams.roleId + body = roleUpdateParams.body.toBuilder() + additionalHeaders = roleUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleUpdateParams.additionalQueryParams.toBuilder() + } /** Role id */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String) = + apply { + this.roleId = roleId + } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: List?) = apply { - body.addMemberPermissions(addMemberPermissions) - } + fun addMemberPermissions(addMemberPermissions: List?) = + apply { + body.addMemberPermissions(addMemberPermissions) + } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: Optional>) = - addMemberPermissions(addMemberPermissions.getOrNull()) + fun addMemberPermissions(addMemberPermissions: Optional>) = addMemberPermissions(addMemberPermissions.getOrNull()) /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: JsonField>) = @@ -435,44 +425,61 @@ private constructor( } /** A list of permissions to add to the role */ - fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { - body.addAddMemberPermission(addMemberPermission) - } + fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = + apply { + body.addAddMemberPermission(addMemberPermission) + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: List?) = apply { - body.addMemberRoles(addMemberRoles) - } + fun addMemberRoles(addMemberRoles: List?) = + apply { + body.addMemberRoles(addMemberRoles) + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: Optional>) = - addMemberRoles(addMemberRoles.getOrNull()) + fun addMemberRoles(addMemberRoles: Optional>) = addMemberRoles(addMemberRoles.getOrNull()) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: JsonField>) = apply { - body.addMemberRoles(addMemberRoles) - } + fun addMemberRoles(addMemberRoles: JsonField>) = + apply { + body.addMemberRoles(addMemberRoles) + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addAddMemberRole(addMemberRole: String) = apply { body.addAddMemberRole(addMemberRole) } + fun addAddMemberRole(addMemberRole: String) = + apply { + body.addAddMemberRole(addMemberRole) + } /** Textual description of the role */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the role */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the role */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the role */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the role */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** A list of permissions to remove from the role */ fun removeMemberPermissions(removeMemberPermissions: List?) = @@ -481,194 +488,227 @@ private constructor( } /** A list of permissions to remove from the role */ - fun removeMemberPermissions( - removeMemberPermissions: Optional> - ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) + fun removeMemberPermissions(removeMemberPermissions: Optional>) = removeMemberPermissions(removeMemberPermissions.getOrNull()) /** A list of permissions to remove from the role */ - fun removeMemberPermissions( - removeMemberPermissions: JsonField> - ) = apply { body.removeMemberPermissions(removeMemberPermissions) } + fun removeMemberPermissions(removeMemberPermissions: JsonField>) = + apply { + body.removeMemberPermissions(removeMemberPermissions) + } /** A list of permissions to remove from the role */ - fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { - body.addRemoveMemberPermission(removeMemberPermission) - } + fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = + apply { + body.addRemoveMemberPermission(removeMemberPermission) + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: List?) = apply { - body.removeMemberRoles(removeMemberRoles) - } + fun removeMemberRoles(removeMemberRoles: List?) = + apply { + body.removeMemberRoles(removeMemberRoles) + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: Optional>) = - removeMemberRoles(removeMemberRoles.getOrNull()) + fun removeMemberRoles(removeMemberRoles: Optional>) = removeMemberRoles(removeMemberRoles.getOrNull()) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { - body.removeMemberRoles(removeMemberRoles) - } + fun removeMemberRoles(removeMemberRoles: JsonField>) = + apply { + body.removeMemberRoles(removeMemberRoles) + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun addRemoveMemberRole(removeMemberRole: String) = apply { - body.addRemoveMemberRole(removeMemberRole) - } + fun addRemoveMemberRole(removeMemberRole: String) = + apply { + body.addRemoveMemberRole(removeMemberRole) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleUpdateParams = RoleUpdateParams( - checkRequired("roleId", roleId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "roleId", roleId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class AddMemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class AddMemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -685,15 +725,16 @@ private constructor( private var validated: Boolean = false - fun validate(): AddMemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): AddMemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -703,11 +744,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [AddMemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AddMemberPermission]. */ @@ -718,87 +761,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addMemberPermission: AddMemberPermission) = apply { - permission = addMemberPermission.permission - restrictObjectType = addMemberPermission.restrictObjectType - additionalProperties = addMemberPermission.additionalProperties.toMutableMap() - } + internal fun from(addMemberPermission: AddMemberPermission) = + apply { + permission = addMemberPermission.permission + restrictObjectType = addMemberPermission.restrictObjectType + additionalProperties = addMemberPermission.additionalProperties.toMutableMap() + } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AddMemberPermission = AddMemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - class Permission @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -837,9 +894,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -862,8 +921,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -885,7 +944,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -906,20 +965,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -928,19 +984,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -990,9 +1048,11 @@ private constructor( * * An instance of [RestrictObjectType] can contain an unknown value in a couple of * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1018,8 +1078,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1044,7 +1104,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1059,8 +1119,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1069,20 +1128,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1091,11 +1147,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AddMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1104,39 +1160,33 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } @NoAutoDetect - class RemoveMemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RemoveMemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -1153,29 +1203,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RemoveMemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): RemoveMemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [RemoveMemberPermission]. + * Returns a mutable builder for constructing an instance of + * [RemoveMemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RemoveMemberPermission]. */ @@ -1186,87 +1240,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeMemberPermission: RemoveMemberPermission) = apply { - permission = removeMemberPermission.permission - restrictObjectType = removeMemberPermission.restrictObjectType - additionalProperties = removeMemberPermission.additionalProperties.toMutableMap() - } + internal fun from(removeMemberPermission: RemoveMemberPermission) = + apply { + permission = removeMemberPermission.permission + restrictObjectType = removeMemberPermission.restrictObjectType + additionalProperties = removeMemberPermission.additionalProperties.toMutableMap() + } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RemoveMemberPermission = RemoveMemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - class Permission @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Permission @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1305,9 +1373,11 @@ private constructor( * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1330,8 +1400,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1353,7 +1423,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1374,20 +1444,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1396,19 +1463,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class RestrictObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1458,9 +1527,11 @@ private constructor( * * An instance of [RestrictObjectType] can contain an unknown value in a couple of * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1486,8 +1557,8 @@ private constructor( * Returns an enum member corresponding to this class instance's value, or * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -1512,7 +1583,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1527,8 +1598,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1537,20 +1607,17 @@ private constructor( * This differs from the [toString] method because that method is primarily for * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1559,11 +1626,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RemoveMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1572,20 +1639,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleUpdateParams{roleId=$roleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleUpdateParams{roleId=$roleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index ff05be5e..6d82da0b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -19,19 +19,14 @@ import java.util.Optional /** Summary of a score's performance */ @NoAutoDetect -class ScoreSummary -@JsonCreator -private constructor( - @JsonProperty("improvements") - @ExcludeMissing - private val improvements: JsonField = JsonMissing.of(), +class ScoreSummary @JsonCreator private constructor( + @JsonProperty("improvements") @ExcludeMissing private val improvements: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("regressions") - @ExcludeMissing - private val regressions: JsonField = JsonMissing.of(), + @JsonProperty("regressions") @ExcludeMissing private val regressions: JsonField = JsonMissing.of(), @JsonProperty("score") @ExcludeMissing private val score: JsonField = JsonMissing.of(), @JsonProperty("diff") @ExcludeMissing private val diff: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Number of improvements in the score */ @@ -55,16 +50,24 @@ private constructor( fun _improvements(): JsonField = improvements /** Name of the score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Number of regressions in the score */ - @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions + @JsonProperty("regressions") + @ExcludeMissing + fun _regressions(): JsonField = regressions /** Average score across all examples */ - @JsonProperty("score") @ExcludeMissing fun _score(): JsonField = score + @JsonProperty("score") + @ExcludeMissing + fun _score(): JsonField = score /** Difference in score between the current and comparison experiment */ - @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff + @JsonProperty("diff") + @ExcludeMissing + fun _diff(): JsonField = diff @JsonAnyGetter @ExcludeMissing @@ -72,19 +75,20 @@ private constructor( private var validated: Boolean = false - fun validate(): ScoreSummary = apply { - if (validated) { - return@apply + fun validate(): ScoreSummary = + apply { + if (validated) { + return@apply + } + + improvements() + name() + regressions() + score() + diff() + validated = true } - improvements() - name() - regressions() - score() - diff() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -93,6 +97,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ScoreSummary]. * * The following fields are required: + * * ```java * .improvements() * .name() @@ -100,7 +105,8 @@ private constructor( * .score() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ScoreSummary]. */ @@ -114,81 +120,112 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scoreSummary: ScoreSummary) = apply { - improvements = scoreSummary.improvements - name = scoreSummary.name - regressions = scoreSummary.regressions - score = scoreSummary.score - diff = scoreSummary.diff - additionalProperties = scoreSummary.additionalProperties.toMutableMap() - } + internal fun from(scoreSummary: ScoreSummary) = + apply { + improvements = scoreSummary.improvements + name = scoreSummary.name + regressions = scoreSummary.regressions + score = scoreSummary.score + diff = scoreSummary.diff + additionalProperties = scoreSummary.additionalProperties.toMutableMap() + } /** Number of improvements in the score */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) /** Number of improvements in the score */ - fun improvements(improvements: JsonField) = apply { this.improvements = improvements } + fun improvements(improvements: JsonField) = + apply { + this.improvements = improvements + } /** Name of the score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Number of regressions in the score */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) /** Number of regressions in the score */ - fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + fun regressions(regressions: JsonField) = + apply { + this.regressions = regressions + } /** Average score across all examples */ fun score(score: Double) = score(JsonField.of(score)) /** Average score across all examples */ - fun score(score: JsonField) = apply { this.score = score } + fun score(score: JsonField) = + apply { + this.score = score + } /** Difference in score between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) /** Difference in score between the current and comparison experiment */ - fun diff(diff: JsonField) = apply { this.diff = diff } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun diff(diff: JsonField) = + apply { + this.diff = diff + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ScoreSummary = ScoreSummary( - checkRequired("improvements", improvements), - checkRequired("name", name), - checkRequired("regressions", regressions), - checkRequired("score", score), - diff, - additionalProperties.toImmutable(), + checkRequired( + "improvements", improvements + ), + checkRequired( + "name", name + ), + checkRequired( + "regressions", regressions + ), + checkRequired( + "score", score + ), + diff, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreSummary && improvements == other.improvements && name == other.name && regressions == other.regressions && score == other.score && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScoreSummary && improvements == other.improvements && name == other.name && regressions == other.regressions && score == other.score && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -197,6 +234,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ScoreSummary{improvements=$improvements, name=$name, regressions=$regressions, score=$score, diff=$diff, additionalProperties=$additionalProperties}" + override fun toString() = "ScoreSummary{improvements=$improvements, name=$name, regressions=$regressions, score=$score, diff=$diff, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt index c7177997..25ebb526 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt @@ -21,12 +21,11 @@ import kotlin.jvm.optionals.getOrNull /** Human-identifying attributes of the span, such as name, type, etc. */ @NoAutoDetect -class SpanAttributes -@JsonCreator -private constructor( +class SpanAttributes @JsonCreator private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the span, for display purposes only */ @@ -36,10 +35,14 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -47,22 +50,24 @@ private constructor( private var validated: Boolean = false - fun validate(): SpanAttributes = apply { - if (validated) { - return@apply - } + fun validate(): SpanAttributes = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [SpanAttributes]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanAttributes]. */ @@ -73,11 +78,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - name = spanAttributes.name - type = spanAttributes.type - additionalProperties = spanAttributes.additionalProperties.toMutableMap() - } + internal fun from(spanAttributes: SpanAttributes) = + apply { + name = spanAttributes.name + type = spanAttributes.type + additionalProperties = spanAttributes.additionalProperties.toMutableMap() + } /** Name of the span, for display purposes only */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -86,7 +92,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the span, for display purposes only */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Type of the span, for display purposes only */ fun type(type: Type?) = type(JsonField.ofNullable(type)) @@ -95,42 +104,61 @@ private constructor( fun type(type: Optional) = type(type.getOrNull()) /** Type of the span, for display purposes only */ - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } - fun build(): SpanAttributes = SpanAttributes(name, type, additionalProperties.toImmutable()) + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toImmutable(), + ) } /** Type of the span, for display purposes only */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -163,9 +191,11 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -180,11 +210,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -200,11 +230,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -220,23 +250,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -245,11 +272,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanAttributes && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanAttributes && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -258,6 +285,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt index ab9266fa..461560c8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -20,31 +20,18 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class SpanIFrame -@JsonCreator -private constructor( +class SpanIFrame @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("post_message") - @ExcludeMissing - private val postMessage: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the span iframe */ @@ -63,37 +50,44 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of span iframe deletion, or null if the span iframe is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the span iframe */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(): Optional = - Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) /** Identifies the user who created the span iframe */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the span iframe */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the span iframe */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url /** Date of span iframe creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of span iframe deletion, or null if the span iframe is still active */ @JsonProperty("deleted_at") @@ -101,18 +95,22 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the span iframe */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing fun _postMessage(): JsonField = postMessage /** Identifies the user who created the span iframe */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -120,23 +118,24 @@ private constructor( private var validated: Boolean = false - fun validate(): SpanIFrame = apply { - if (validated) { - return@apply + fun validate(): SpanIFrame = + apply { + if (validated) { + return@apply + } + + id() + name() + projectId() + url() + created() + deletedAt() + description() + postMessage() + userId() + validated = true } - id() - name() - projectId() - url() - created() - deletedAt() - description() - postMessage() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -145,6 +144,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [SpanIFrame]. * * The following fields are required: + * * ```java * .id() * .name() @@ -152,7 +152,8 @@ private constructor( * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIFrame]. */ @@ -170,42 +171,55 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanIFrame: SpanIFrame) = apply { - id = spanIFrame.id - name = spanIFrame.name - projectId = spanIFrame.projectId - url = spanIFrame.url - created = spanIFrame.created - deletedAt = spanIFrame.deletedAt - description = spanIFrame.description - postMessage = spanIFrame.postMessage - userId = spanIFrame.userId - additionalProperties = spanIFrame.additionalProperties.toMutableMap() - } + internal fun from(spanIFrame: SpanIFrame) = + apply { + id = spanIFrame.id + name = spanIFrame.name + projectId = spanIFrame.projectId + url = spanIFrame.url + created = spanIFrame.created + deletedAt = spanIFrame.deletedAt + description = spanIFrame.description + postMessage = spanIFrame.postMessage + userId = spanIFrame.userId + additionalProperties = spanIFrame.additionalProperties.toMutableMap() + } /** Unique identifier for the span iframe */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the span iframe */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) /** Name of the span iframe */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { this.url = url } + fun url(url: JsonField) = + apply { + this.url = url + } /** Date of span iframe creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -214,7 +228,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of span iframe creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of span iframe deletion, or null if the span iframe is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -223,7 +240,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of span iframe deletion, or null if the span iframe is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -232,31 +252,37 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { this.postMessage = postMessage } + fun postMessage(postMessage: JsonField) = + apply { + this.postMessage = postMessage + } /** Identifies the user who created the span iframe */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -265,48 +291,66 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the span iframe */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SpanIFrame = SpanIFrame( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("url", url), - created, - deletedAt, - description, - postMessage, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "url", url + ), + created, + deletedAt, + description, + postMessage, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIFrame && id == other.id && name == other.name && projectId == other.projectId && url == other.url && created == other.created && deletedAt == other.deletedAt && description == other.description && postMessage == other.postMessage && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanIFrame && id == other.id && name == other.name && projectId == other.projectId && url == other.url && created == other.created && deletedAt == other.deletedAt && description == other.description && postMessage == other.postMessage && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -315,6 +359,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SpanIFrame{id=$id, name=$name, projectId=$projectId, url=$url, created=$created, deletedAt=$deletedAt, description=$description, postMessage=$postMessage, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "SpanIFrame{id=$id, name=$name, projectId=$projectId, url=$url, created=$created, deletedAt=$deletedAt, description=$description, postMessage=$postMessage, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index 9f81c14e..29e104af 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will return the existing span_iframe unmodified + * Create a new span_iframe. If there is an existing span_iframe with the same name + * as the one specified in the request, will return the existing span_iframe + * unmodified */ -class SpanIframeCreateParams -private constructor( +class SpanIframeCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the span iframe */ @@ -45,8 +46,8 @@ private constructor( fun description(): Optional = body.description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(): Optional = body.postMessage() @@ -63,8 +64,8 @@ private constructor( fun _description(): JsonField = body._description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun _postMessage(): JsonField = body._postMessage() @@ -74,31 +75,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("post_message") - @ExcludeMissing - private val postMessage: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the span iframe */ @@ -111,24 +103,28 @@ private constructor( fun url(): String = url.getRequired("url") /** Textual description of the span iframe */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(): Optional = - Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) /** Name of the span iframe */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url /** Textual description of the span iframe */ @JsonProperty("description") @@ -136,8 +132,8 @@ private constructor( fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing @@ -149,19 +145,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + url() + description() + postMessage() + validated = true } - name() - projectId() - url() - description() - postMessage() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -170,13 +167,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -190,32 +189,42 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - url = body.url - description = body.description - postMessage = body.postMessage - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + url = body.url + description = body.description + postMessage = body.postMessage + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) /** Name of the span iframe */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { this.url = url } + fun url(url: JsonField) = + apply { + this.url = url + } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -224,72 +233,87 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { - this.postMessage = postMessage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun postMessage(postMessage: JsonField) = + apply { + this.postMessage = postMessage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("url", url), - description, - postMessage, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "url", url + ), + description, + postMessage, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -298,8 +322,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -307,16 +330,19 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeCreateParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeCreateParams]. */ @@ -328,198 +354,262 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeCreateParams: SpanIframeCreateParams) = apply { - body = spanIframeCreateParams.body.toBuilder() - additionalHeaders = spanIframeCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeCreateParams: SpanIframeCreateParams) = + apply { + body = spanIframeCreateParams.body.toBuilder() + additionalHeaders = spanIframeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeCreateParams.additionalQueryParams.toBuilder() + } /** Name of the span iframe */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the span iframe */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** URL to embed the project viewer in an iframe */ - fun url(url: String) = apply { body.url(url) } + fun url(url: String) = + apply { + body.url(url) + } /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { body.url(url) } + fun url(url: JsonField) = + apply { + body.url(url) + } /** Textual description of the span iframe */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the span iframe */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: Boolean?) = + apply { + body.postMessage(postMessage) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: JsonField) = + apply { + body.postMessage(postMessage) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeCreateParams = SpanIframeCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt index ca88a657..a39365d1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a span_iframe object by its id */ -class SpanIframeDeleteParams -private constructor( +class SpanIframeDeleteParams private constructor( private val spanIframeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** SpanIframe id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> spanIframeId - else -> "" - } + return when (index) { + 0 -> spanIframeId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeDeleteParams]. * * The following fields are required: + * * ```java * .spanIframeId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanIframeDeleteParams: SpanIframeDeleteParams) = apply { - spanIframeId = spanIframeDeleteParams.spanIframeId - additionalHeaders = spanIframeDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - spanIframeDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(spanIframeDeleteParams: SpanIframeDeleteParams) = + apply { + spanIframeId = spanIframeDeleteParams.spanIframeId + additionalHeaders = spanIframeDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = spanIframeDeleteParams.additionalBodyProperties.toMutableMap() + } /** SpanIframe id */ - fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + fun spanIframeId(spanIframeId: String) = + apply { + this.spanIframeId = spanIframeId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): SpanIframeDeleteParams = SpanIframeDeleteParams( - checkRequired("spanIframeId", spanIframeId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "spanIframeId", spanIframeId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeDeleteParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeDeleteParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt index 26329957..2564c749 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.SpanIframeService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ -class SpanIframeListPage -private constructor( +class SpanIframeListPage private constructor( private val spanIframesService: SpanIframeService, private val params: SpanIframeListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeListPage && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is SpanIframeListPage && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ - override fun toString() = - "SpanIframeListPage{spanIframesService=$spanIframesService, params=$params, response=$response}" + override fun toString() = "SpanIframeListPage{spanIframesService=$spanIframesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - SpanIframeListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - SpanIframeListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(SpanIframeListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(SpanIframeListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { spanIframesService.list(it) } + return getNextPageParams().map { spanIframesService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - spanIframesService: SpanIframeService, - params: SpanIframeListParams, - response: Response, - ) = SpanIframeListPage(spanIframesService, params, response) + fun of(spanIframesService: SpanIframeService, params: SpanIframeListParams, response: Response) = + SpanIframeListPage( + spanIframesService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [SpanIframeListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: SpanIframeListPage) : Iterable { + class AutoPager( + private val firstPage: SpanIframeListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt index b851e390..bf9d1da6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.SpanIframeServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ -class SpanIframeListPageAsync -private constructor( +class SpanIframeListPageAsync private constructor( private val spanIframesService: SpanIframeServiceAsync, private val params: SpanIframeListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeListPageAsync && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is SpanIframeListPageAsync && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ - override fun toString() = - "SpanIframeListPageAsync{spanIframesService=$spanIframesService, params=$params, response=$response}" + override fun toString() = "SpanIframeListPageAsync{spanIframesService=$spanIframesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - SpanIframeListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - SpanIframeListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(SpanIframeListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(SpanIframeListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { spanIframesService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + spanIframesService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - spanIframesService: SpanIframeServiceAsync, - params: SpanIframeListParams, - response: Response, - ) = SpanIframeListPageAsync(spanIframesService, params, response) + fun of(spanIframesService: SpanIframeServiceAsync, params: SpanIframeListParams, response: Response) = + SpanIframeListPageAsync( + spanIframesService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -151,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: SpanIframeListPageAsync) { + class AutoPager( + private val firstPage: SpanIframeListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (SpanIFrame) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (SpanIFrame) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 87ccce77..51eca91e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ -class SpanIframeListParams -private constructor( +class SpanIframeListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -36,20 +35,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,54 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.spanIframeName?.let { queryParams.put("span_iframe_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.spanIframeName?.let { + queryParams.put( + "span_iframe_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): SpanIframeListParams = builder().build() + @JvmStatic + fun none(): SpanIframeListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [SpanIframeListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [SpanIframeListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeListParams]. */ @@ -113,61 +142,71 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeListParams: SpanIframeListParams) = apply { - endingBefore = spanIframeListParams.endingBefore - ids = spanIframeListParams.ids - limit = spanIframeListParams.limit - orgName = spanIframeListParams.orgName - spanIframeName = spanIframeListParams.spanIframeName - startingAfter = spanIframeListParams.startingAfter - additionalHeaders = spanIframeListParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeListParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeListParams: SpanIframeListParams) = + apply { + endingBefore = spanIframeListParams.endingBefore + ids = spanIframeListParams.ids + limit = spanIframeListParams.limit + orgName = spanIframeListParams.orgName + spanIframeName = spanIframeListParams.spanIframeName + startingAfter = spanIframeListParams.startingAfter + additionalHeaders = spanIframeListParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -176,159 +215,192 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the span_iframe to search for */ - fun spanIframeName(spanIframeName: String?) = apply { this.spanIframeName = spanIframeName } + fun spanIframeName(spanIframeName: String?) = + apply { + this.spanIframeName = spanIframeName + } /** Name of the span_iframe to search for */ - fun spanIframeName(spanIframeName: Optional) = - spanIframeName(spanIframeName.getOrNull()) + fun spanIframeName(spanIframeName: Optional) = spanIframeName(spanIframeName.getOrNull()) /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeListParams = SpanIframeListParams( - endingBefore, - ids, - limit, - orgName, - spanIframeName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + spanIframeName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -346,19 +418,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -373,12 +445,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -388,60 +465,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && spanIframeName == other.spanIframeName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && spanIframeName == other.spanIframeName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, spanIframeName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index d3dc8f16..ae6144aa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will replace the existing span_iframe with the provided fields + * Create or replace span_iframe. If there is an existing span_iframe with the same + * name as the one specified in the request, will replace the existing span_iframe + * with the provided fields */ -class SpanIframeReplaceParams -private constructor( +class SpanIframeReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the span iframe */ @@ -45,8 +46,8 @@ private constructor( fun description(): Optional = body.description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(): Optional = body.postMessage() @@ -63,8 +64,8 @@ private constructor( fun _description(): JsonField = body._description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun _postMessage(): JsonField = body._postMessage() @@ -74,31 +75,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("post_message") - @ExcludeMissing - private val postMessage: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the span iframe */ @@ -111,24 +103,28 @@ private constructor( fun url(): String = url.getRequired("url") /** Textual description of the span iframe */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(): Optional = - Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) /** Name of the span iframe */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url /** Textual description of the span iframe */ @JsonProperty("description") @@ -136,8 +132,8 @@ private constructor( fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing @@ -149,19 +145,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + url() + description() + postMessage() + validated = true } - name() - projectId() - url() - description() - postMessage() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -170,13 +167,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -190,32 +189,42 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - url = body.url - description = body.description - postMessage = body.postMessage - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + url = body.url + description = body.description + postMessage = body.postMessage + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) /** Name of the span iframe */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { this.url = url } + fun url(url: JsonField) = + apply { + this.url = url + } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -224,72 +233,87 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { - this.postMessage = postMessage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun postMessage(postMessage: JsonField) = + apply { + this.postMessage = postMessage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("url", url), - description, - postMessage, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "url", url + ), + description, + postMessage, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -298,8 +322,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -307,16 +330,19 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeReplaceParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeReplaceParams]. */ @@ -328,198 +354,262 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeReplaceParams: SpanIframeReplaceParams) = apply { - body = spanIframeReplaceParams.body.toBuilder() - additionalHeaders = spanIframeReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeReplaceParams: SpanIframeReplaceParams) = + apply { + body = spanIframeReplaceParams.body.toBuilder() + additionalHeaders = spanIframeReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the span iframe */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the span iframe */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** URL to embed the project viewer in an iframe */ - fun url(url: String) = apply { body.url(url) } + fun url(url: String) = + apply { + body.url(url) + } /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { body.url(url) } + fun url(url: JsonField) = + apply { + body.url(url) + } /** Textual description of the span iframe */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the span iframe */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: Boolean?) = + apply { + body.postMessage(postMessage) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: JsonField) = + apply { + body.postMessage(postMessage) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeReplaceParams = SpanIframeReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt index 241438c1..6059ad2c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a span_iframe object by its id */ -class SpanIframeRetrieveParams -private constructor( +class SpanIframeRetrieveParams private constructor( private val spanIframeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** SpanIframe id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> spanIframeId - else -> "" - } + return when (index) { + 0 -> spanIframeId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeRetrieveParams]. * * The following fields are required: + * * ```java * .spanIframeId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeRetrieveParams: SpanIframeRetrieveParams) = apply { - spanIframeId = spanIframeRetrieveParams.spanIframeId - additionalHeaders = spanIframeRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeRetrieveParams: SpanIframeRetrieveParams) = + apply { + spanIframeId = spanIframeRetrieveParams.spanIframeId + additionalHeaders = spanIframeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeRetrieveParams.additionalQueryParams.toBuilder() + } /** SpanIframe id */ - fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + fun spanIframeId(spanIframeId: String) = + apply { + this.spanIframeId = spanIframeId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeRetrieveParams = SpanIframeRetrieveParams( - checkRequired("spanIframeId", spanIframeId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "spanIframeId", spanIframeId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeRetrieveParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeRetrieveParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 50735234..15870507 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a span_iframe object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a span_iframe object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class SpanIframeUpdateParams -private constructor( +class SpanIframeUpdateParams private constructor( private val spanIframeId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** SpanIframe id */ @@ -41,8 +41,8 @@ private constructor( fun name(): Optional = body.name() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(): Optional = body.postMessage() @@ -53,8 +53,8 @@ private constructor( fun _name(): JsonField = body._name() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun _postMessage(): JsonField = body._postMessage() @@ -67,60 +67,58 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> spanIframeId - else -> "" - } + return when (index) { + 0 -> spanIframeId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("post_message") - @ExcludeMissing - private val postMessage: JsonField = JsonMissing.of(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the span iframe */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(): Optional = - Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) /** URL to embed the project viewer in an iframe */ fun url(): Optional = Optional.ofNullable(url.getNullable("url")) /** Name of the span iframe */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing fun _postMessage(): JsonField = postMessage /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -128,23 +126,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + postMessage() + url() + validated = true } - name() - postMessage() - url() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -156,12 +156,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - postMessage = body.postMessage - url = body.url - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + postMessage = body.postMessage + url = body.url + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the span iframe */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -170,33 +171,37 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the span iframe */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { - this.postMessage = postMessage - } + fun postMessage(postMessage: JsonField) = + apply { + this.postMessage = postMessage + } /** URL to embed the project viewer in an iframe */ fun url(url: String?) = url(JsonField.ofNullable(url)) @@ -205,36 +210,52 @@ private constructor( fun url(url: Optional) = url(url.getOrNull()) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { this.url = url } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = Body(name, postMessage, url, additionalProperties.toImmutable()) + fun url(url: JsonField) = + apply { + this.url = url + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = + Body( + name, + postMessage, + url, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -243,8 +264,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -252,14 +272,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeUpdateParams]. * * The following fields are required: + * * ```java * .spanIframeId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeUpdateParams]. */ @@ -272,194 +295,251 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeUpdateParams: SpanIframeUpdateParams) = apply { - spanIframeId = spanIframeUpdateParams.spanIframeId - body = spanIframeUpdateParams.body.toBuilder() - additionalHeaders = spanIframeUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeUpdateParams: SpanIframeUpdateParams) = + apply { + spanIframeId = spanIframeUpdateParams.spanIframeId + body = spanIframeUpdateParams.body.toBuilder() + additionalHeaders = spanIframeUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeUpdateParams.additionalQueryParams.toBuilder() + } /** SpanIframe id */ - fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + fun spanIframeId(spanIframeId: String) = + apply { + this.spanIframeId = spanIframeId + } /** Name of the span iframe */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the span iframe */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the span iframe */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: Boolean?) = + apply { + body.postMessage(postMessage) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: JsonField) = + apply { + body.postMessage(postMessage) + } /** URL to embed the project viewer in an iframe */ - fun url(url: String?) = apply { body.url(url) } + fun url(url: String?) = + apply { + body.url(url) + } /** URL to embed the project viewer in an iframe */ fun url(url: Optional) = url(url.getOrNull()) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { body.url(url) } + fun url(url: JsonField) = + apply { + body.url(url) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeUpdateParams = SpanIframeUpdateParams( - checkRequired("spanIframeId", spanIframeId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "spanIframeId", spanIframeId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeUpdateParams{spanIframeId=$spanIframeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeUpdateParams{spanIframeId=$spanIframeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 949d6300..9d77823b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -20,25 +20,14 @@ import kotlin.jvm.optionals.getOrNull /** Summary of a dataset */ @NoAutoDetect -class SummarizeDatasetResponse -@JsonCreator -private constructor( - @JsonProperty("dataset_name") - @ExcludeMissing - private val datasetName: JsonField = JsonMissing.of(), - @JsonProperty("dataset_url") - @ExcludeMissing - private val datasetUrl: JsonField = JsonMissing.of(), - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("project_url") - @ExcludeMissing - private val projectUrl: JsonField = JsonMissing.of(), - @JsonProperty("data_summary") - @ExcludeMissing - private val dataSummary: JsonField = JsonMissing.of(), +class SummarizeDatasetResponse @JsonCreator private constructor( + @JsonProperty("dataset_name") @ExcludeMissing private val datasetName: JsonField = JsonMissing.of(), + @JsonProperty("dataset_url") @ExcludeMissing private val datasetUrl: JsonField = JsonMissing.of(), + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("project_url") @ExcludeMissing private val projectUrl: JsonField = JsonMissing.of(), + @JsonProperty("data_summary") @ExcludeMissing private val dataSummary: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the dataset */ @@ -54,8 +43,7 @@ private constructor( fun projectUrl(): String = projectUrl.getRequired("project_url") /** Summary of a dataset's data */ - fun dataSummary(): Optional = - Optional.ofNullable(dataSummary.getNullable("data_summary")) + fun dataSummary(): Optional = Optional.ofNullable(dataSummary.getNullable("data_summary")) /** Name of the dataset */ @JsonProperty("dataset_name") @@ -63,7 +51,9 @@ private constructor( fun _datasetName(): JsonField = datasetName /** URL to the dataset's page in the Braintrust app */ - @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl(): JsonField = datasetUrl + @JsonProperty("dataset_url") + @ExcludeMissing + fun _datasetUrl(): JsonField = datasetUrl /** Name of the project that the dataset belongs to */ @JsonProperty("project_name") @@ -71,7 +61,9 @@ private constructor( fun _projectName(): JsonField = projectName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl + @JsonProperty("project_url") + @ExcludeMissing + fun _projectUrl(): JsonField = projectUrl /** Summary of a dataset's data */ @JsonProperty("data_summary") @@ -84,27 +76,30 @@ private constructor( private var validated: Boolean = false - fun validate(): SummarizeDatasetResponse = apply { - if (validated) { - return@apply + fun validate(): SummarizeDatasetResponse = + apply { + if (validated) { + return@apply + } + + datasetName() + datasetUrl() + projectName() + projectUrl() + dataSummary().ifPresent { it.validate() } + validated = true } - datasetName() - datasetUrl() - projectName() - projectUrl() - dataSummary().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [SummarizeDatasetResponse]. + * Returns a mutable builder for constructing an instance of + * [SummarizeDatasetResponse]. * * The following fields are required: + * * ```java * .datasetName() * .datasetUrl() @@ -112,7 +107,8 @@ private constructor( * .projectUrl() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SummarizeDatasetResponse]. */ @@ -126,38 +122,51 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(summarizeDatasetResponse: SummarizeDatasetResponse) = apply { - datasetName = summarizeDatasetResponse.datasetName - datasetUrl = summarizeDatasetResponse.datasetUrl - projectName = summarizeDatasetResponse.projectName - projectUrl = summarizeDatasetResponse.projectUrl - dataSummary = summarizeDatasetResponse.dataSummary - additionalProperties = summarizeDatasetResponse.additionalProperties.toMutableMap() - } + internal fun from(summarizeDatasetResponse: SummarizeDatasetResponse) = + apply { + datasetName = summarizeDatasetResponse.datasetName + datasetUrl = summarizeDatasetResponse.datasetUrl + projectName = summarizeDatasetResponse.projectName + projectUrl = summarizeDatasetResponse.projectUrl + dataSummary = summarizeDatasetResponse.dataSummary + additionalProperties = summarizeDatasetResponse.additionalProperties.toMutableMap() + } /** Name of the dataset */ fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) /** Name of the dataset */ - fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } + fun datasetName(datasetName: JsonField) = + apply { + this.datasetName = datasetName + } /** URL to the dataset's page in the Braintrust app */ fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) /** URL to the dataset's page in the Braintrust app */ - fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } + fun datasetUrl(datasetUrl: JsonField) = + apply { + this.datasetUrl = datasetUrl + } /** Name of the project that the dataset belongs to */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** Name of the project that the dataset belongs to */ - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) /** URL to the project's page in the Braintrust app */ - fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } + fun projectUrl(projectUrl: JsonField) = + apply { + this.projectUrl = projectUrl + } /** Summary of a dataset's data */ fun dataSummary(dataSummary: DataSummary?) = dataSummary(JsonField.ofNullable(dataSummary)) @@ -166,46 +175,62 @@ private constructor( fun dataSummary(dataSummary: Optional) = dataSummary(dataSummary.getOrNull()) /** Summary of a dataset's data */ - fun dataSummary(dataSummary: JsonField) = apply { - this.dataSummary = dataSummary - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dataSummary(dataSummary: JsonField) = + apply { + this.dataSummary = dataSummary + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SummarizeDatasetResponse = SummarizeDatasetResponse( - checkRequired("datasetName", datasetName), - checkRequired("datasetUrl", datasetUrl), - checkRequired("projectName", projectName), - checkRequired("projectUrl", projectUrl), - dataSummary, - additionalProperties.toImmutable(), + checkRequired( + "datasetName", datasetName + ), + checkRequired( + "datasetUrl", datasetUrl + ), + checkRequired( + "projectName", projectName + ), + checkRequired( + "projectUrl", projectUrl + ), + dataSummary, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SummarizeDatasetResponse && datasetName == other.datasetName && datasetUrl == other.datasetUrl && projectName == other.projectName && projectUrl == other.projectUrl && dataSummary == other.dataSummary && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeDatasetResponse && datasetName == other.datasetName && datasetUrl == other.datasetUrl && projectName == other.projectName && projectUrl == other.projectUrl && dataSummary == other.dataSummary && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -214,6 +239,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SummarizeDatasetResponse{datasetName=$datasetName, datasetUrl=$datasetUrl, projectName=$projectName, projectUrl=$projectUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" + override fun toString() = "SummarizeDatasetResponse{datasetName=$datasetName, datasetUrl=$datasetUrl, projectName=$projectName, projectUrl=$projectUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index b23ca9e9..05ec4392 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -20,31 +20,16 @@ import kotlin.jvm.optionals.getOrNull /** Summary of an experiment */ @NoAutoDetect -class SummarizeExperimentResponse -@JsonCreator -private constructor( - @JsonProperty("experiment_name") - @ExcludeMissing - private val experimentName: JsonField = JsonMissing.of(), - @JsonProperty("experiment_url") - @ExcludeMissing - private val experimentUrl: JsonField = JsonMissing.of(), - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("project_url") - @ExcludeMissing - private val projectUrl: JsonField = JsonMissing.of(), - @JsonProperty("comparison_experiment_name") - @ExcludeMissing - private val comparisonExperimentName: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), +class SummarizeExperimentResponse @JsonCreator private constructor( + @JsonProperty("experiment_name") @ExcludeMissing private val experimentName: JsonField = JsonMissing.of(), + @JsonProperty("experiment_url") @ExcludeMissing private val experimentUrl: JsonField = JsonMissing.of(), + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("project_url") @ExcludeMissing private val projectUrl: JsonField = JsonMissing.of(), + @JsonProperty("comparison_experiment_name") @ExcludeMissing private val comparisonExperimentName: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the experiment */ @@ -60,8 +45,7 @@ private constructor( fun projectUrl(): String = projectUrl.getRequired("project_url") /** The experiment which scores are baselined against */ - fun comparisonExperimentName(): Optional = - Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) + fun comparisonExperimentName(): Optional = Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) /** Summary of the experiment's metrics */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) @@ -85,7 +69,9 @@ private constructor( fun _projectName(): JsonField = projectName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl + @JsonProperty("project_url") + @ExcludeMissing + fun _projectUrl(): JsonField = projectUrl /** The experiment which scores are baselined against */ @JsonProperty("comparison_experiment_name") @@ -93,10 +79,14 @@ private constructor( fun _comparisonExperimentName(): JsonField = comparisonExperimentName /** Summary of the experiment's metrics */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** Summary of the experiment's scores */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores @JsonAnyGetter @ExcludeMissing @@ -104,29 +94,32 @@ private constructor( private var validated: Boolean = false - fun validate(): SummarizeExperimentResponse = apply { - if (validated) { - return@apply - } + fun validate(): SummarizeExperimentResponse = + apply { + if (validated) { + return@apply + } - experimentName() - experimentUrl() - projectName() - projectUrl() - comparisonExperimentName() - metrics().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - validated = true - } + experimentName() + experimentUrl() + projectName() + projectUrl() + comparisonExperimentName() + metrics().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [SummarizeExperimentResponse]. + * Returns a mutable builder for constructing an instance of + * [SummarizeExperimentResponse]. * * The following fields are required: + * * ```java * .experimentName() * .experimentUrl() @@ -134,7 +127,8 @@ private constructor( * .projectUrl() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SummarizeExperimentResponse]. */ @@ -150,57 +144,65 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(summarizeExperimentResponse: SummarizeExperimentResponse) = apply { - experimentName = summarizeExperimentResponse.experimentName - experimentUrl = summarizeExperimentResponse.experimentUrl - projectName = summarizeExperimentResponse.projectName - projectUrl = summarizeExperimentResponse.projectUrl - comparisonExperimentName = summarizeExperimentResponse.comparisonExperimentName - metrics = summarizeExperimentResponse.metrics - scores = summarizeExperimentResponse.scores - additionalProperties = summarizeExperimentResponse.additionalProperties.toMutableMap() - } + internal fun from(summarizeExperimentResponse: SummarizeExperimentResponse) = + apply { + experimentName = summarizeExperimentResponse.experimentName + experimentUrl = summarizeExperimentResponse.experimentUrl + projectName = summarizeExperimentResponse.projectName + projectUrl = summarizeExperimentResponse.projectUrl + comparisonExperimentName = summarizeExperimentResponse.comparisonExperimentName + metrics = summarizeExperimentResponse.metrics + scores = summarizeExperimentResponse.scores + additionalProperties = summarizeExperimentResponse.additionalProperties.toMutableMap() + } /** Name of the experiment */ fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) /** Name of the experiment */ - fun experimentName(experimentName: JsonField) = apply { - this.experimentName = experimentName - } + fun experimentName(experimentName: JsonField) = + apply { + this.experimentName = experimentName + } /** URL to the experiment's page in the Braintrust app */ fun experimentUrl(experimentUrl: String) = experimentUrl(JsonField.of(experimentUrl)) /** URL to the experiment's page in the Braintrust app */ - fun experimentUrl(experimentUrl: JsonField) = apply { - this.experimentUrl = experimentUrl - } + fun experimentUrl(experimentUrl: JsonField) = + apply { + this.experimentUrl = experimentUrl + } /** Name of the project that the experiment belongs to */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** Name of the project that the experiment belongs to */ - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) /** URL to the project's page in the Braintrust app */ - fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } + fun projectUrl(projectUrl: JsonField) = + apply { + this.projectUrl = projectUrl + } /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: String?) = - comparisonExperimentName(JsonField.ofNullable(comparisonExperimentName)) + fun comparisonExperimentName(comparisonExperimentName: String?) = comparisonExperimentName(JsonField.ofNullable(comparisonExperimentName)) /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: Optional) = - comparisonExperimentName(comparisonExperimentName.getOrNull()) + fun comparisonExperimentName(comparisonExperimentName: Optional) = comparisonExperimentName(comparisonExperimentName.getOrNull()) /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: JsonField) = apply { - this.comparisonExperimentName = comparisonExperimentName - } + fun comparisonExperimentName(comparisonExperimentName: JsonField) = + apply { + this.comparisonExperimentName = comparisonExperimentName + } /** Summary of the experiment's metrics */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) @@ -209,7 +211,10 @@ private constructor( fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** Summary of the experiment's metrics */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** Summary of the experiment's scores */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) @@ -218,47 +223,63 @@ private constructor( fun scores(scores: Optional) = scores(scores.getOrNull()) /** Summary of the experiment's scores */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SummarizeExperimentResponse = SummarizeExperimentResponse( - checkRequired("experimentName", experimentName), - checkRequired("experimentUrl", experimentUrl), - checkRequired("projectName", projectName), - checkRequired("projectUrl", projectUrl), - comparisonExperimentName, - metrics, - scores, - additionalProperties.toImmutable(), + checkRequired( + "experimentName", experimentName + ), + checkRequired( + "experimentUrl", experimentUrl + ), + checkRequired( + "projectName", projectName + ), + checkRequired( + "projectUrl", projectUrl + ), + comparisonExperimentName, + metrics, + scores, + additionalProperties.toImmutable(), ) } /** Summary of the experiment's metrics */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metrics @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -267,20 +288,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -289,38 +312,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - additionalProperties = metrics.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metrics: Metrics) = + apply { + additionalProperties = metrics.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -334,11 +365,9 @@ private constructor( /** Summary of the experiment's scores */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -347,20 +376,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -369,38 +400,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -413,11 +452,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SummarizeExperimentResponse && experimentName == other.experimentName && experimentUrl == other.experimentUrl && projectName == other.projectName && projectUrl == other.projectUrl && comparisonExperimentName == other.comparisonExperimentName && metrics == other.metrics && scores == other.scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeExperimentResponse && experimentName == other.experimentName && experimentUrl == other.experimentUrl && projectName == other.projectName && projectUrl == other.projectUrl && comparisonExperimentName == other.comparisonExperimentName && metrics == other.metrics && scores == other.scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -426,6 +465,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SummarizeExperimentResponse{experimentName=$experimentName, experimentUrl=$experimentUrl, projectName=$projectName, projectUrl=$projectUrl, comparisonExperimentName=$comparisonExperimentName, metrics=$metrics, scores=$scores, additionalProperties=$additionalProperties}" + override fun toString() = "SummarizeExperimentResponse{experimentName=$experimentName, experimentUrl=$experimentUrl, projectName=$projectName, projectUrl=$projectUrl, comparisonExperimentName=$comparisonExperimentName, metrics=$metrics, scores=$scores, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index a3a17747..b8b095b3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -8,11 +8,14 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import java.util.Objects -/** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ -class TopLevelHelloWorldParams -private constructor( +/** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ +class TopLevelHelloWorldParams private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { fun _additionalHeaders(): Headers = additionalHeaders @@ -27,10 +30,15 @@ private constructor( companion object { - @JvmStatic fun none(): TopLevelHelloWorldParams = builder().build() + @JvmStatic + fun none(): TopLevelHelloWorldParams = builder().build() - /** Returns a mutable builder for constructing an instance of [TopLevelHelloWorldParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [TopLevelHelloWorldParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [TopLevelHelloWorldParams]. */ @@ -41,123 +49,151 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(topLevelHelloWorldParams: TopLevelHelloWorldParams) = apply { - additionalHeaders = topLevelHelloWorldParams.additionalHeaders.toBuilder() - additionalQueryParams = topLevelHelloWorldParams.additionalQueryParams.toBuilder() - } + internal fun from(topLevelHelloWorldParams: TopLevelHelloWorldParams) = + apply { + additionalHeaders = topLevelHelloWorldParams.additionalHeaders.toBuilder() + additionalQueryParams = topLevelHelloWorldParams.additionalQueryParams.toBuilder() + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): TopLevelHelloWorldParams = - TopLevelHelloWorldParams(additionalHeaders.build(), additionalQueryParams.build()) + TopLevelHelloWorldParams( + additionalHeaders.build(), additionalQueryParams.build() + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is TopLevelHelloWorldParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is TopLevelHelloWorldParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index b064f7aa..a2e28021 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -20,24 +20,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class User -@JsonCreator -private constructor( +class User @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("avatar_url") - @ExcludeMissing - private val avatarUrl: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("avatar_url") @ExcludeMissing private val avatarUrl: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("email") @ExcludeMissing private val email: JsonField = JsonMissing.of(), - @JsonProperty("family_name") - @ExcludeMissing - private val familyName: JsonField = JsonMissing.of(), - @JsonProperty("given_name") - @ExcludeMissing - private val givenName: JsonField = JsonMissing.of(), + @JsonProperty("family_name") @ExcludeMissing private val familyName: JsonField = JsonMissing.of(), + @JsonProperty("given_name") @ExcludeMissing private val givenName: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the user */ @@ -59,22 +50,34 @@ private constructor( fun givenName(): Optional = Optional.ofNullable(givenName.getNullable("given_name")) /** Unique identifier for the user */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** URL of the user's Avatar image */ - @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl(): JsonField = avatarUrl + @JsonProperty("avatar_url") + @ExcludeMissing + fun _avatarUrl(): JsonField = avatarUrl /** Date of user creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** The user's email */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + @JsonProperty("email") + @ExcludeMissing + fun _email(): JsonField = email /** Family name of the user */ - @JsonProperty("family_name") @ExcludeMissing fun _familyName(): JsonField = familyName + @JsonProperty("family_name") + @ExcludeMissing + fun _familyName(): JsonField = familyName /** Given name of the user */ - @JsonProperty("given_name") @ExcludeMissing fun _givenName(): JsonField = givenName + @JsonProperty("given_name") + @ExcludeMissing + fun _givenName(): JsonField = givenName @JsonAnyGetter @ExcludeMissing @@ -82,20 +85,21 @@ private constructor( private var validated: Boolean = false - fun validate(): User = apply { - if (validated) { - return@apply + fun validate(): User = + apply { + if (validated) { + return@apply + } + + id() + avatarUrl() + created() + email() + familyName() + givenName() + validated = true } - id() - avatarUrl() - created() - email() - familyName() - givenName() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -104,11 +108,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [User]. * * The following fields are required: + * * ```java * .id() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [User]. */ @@ -123,21 +129,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(user: User) = apply { - id = user.id - avatarUrl = user.avatarUrl - created = user.created - email = user.email - familyName = user.familyName - givenName = user.givenName - additionalProperties = user.additionalProperties.toMutableMap() - } + internal fun from(user: User) = + apply { + id = user.id + avatarUrl = user.avatarUrl + created = user.created + email = user.email + familyName = user.familyName + givenName = user.givenName + additionalProperties = user.additionalProperties.toMutableMap() + } /** Unique identifier for the user */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the user */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** URL of the user's Avatar image */ fun avatarUrl(avatarUrl: String?) = avatarUrl(JsonField.ofNullable(avatarUrl)) @@ -146,7 +156,10 @@ private constructor( fun avatarUrl(avatarUrl: Optional) = avatarUrl(avatarUrl.getOrNull()) /** URL of the user's Avatar image */ - fun avatarUrl(avatarUrl: JsonField) = apply { this.avatarUrl = avatarUrl } + fun avatarUrl(avatarUrl: JsonField) = + apply { + this.avatarUrl = avatarUrl + } /** Date of user creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -155,7 +168,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of user creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** The user's email */ fun email(email: String?) = email(JsonField.ofNullable(email)) @@ -164,7 +180,10 @@ private constructor( fun email(email: Optional) = email(email.getOrNull()) /** The user's email */ - fun email(email: JsonField) = apply { this.email = email } + fun email(email: JsonField) = + apply { + this.email = email + } /** Family name of the user */ fun familyName(familyName: String?) = familyName(JsonField.ofNullable(familyName)) @@ -173,7 +192,10 @@ private constructor( fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) /** Family name of the user */ - fun familyName(familyName: JsonField) = apply { this.familyName = familyName } + fun familyName(familyName: JsonField) = + apply { + this.familyName = familyName + } /** Given name of the user */ fun givenName(givenName: String?) = givenName(JsonField.ofNullable(givenName)) @@ -182,45 +204,57 @@ private constructor( fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) /** Given name of the user */ - fun givenName(givenName: JsonField) = apply { this.givenName = givenName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun givenName(givenName: JsonField) = + apply { + this.givenName = givenName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): User = User( - checkRequired("id", id), - avatarUrl, - created, - email, - familyName, - givenName, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + avatarUrl, + created, + email, + familyName, + givenName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is User && id == other.id && avatarUrl == other.avatarUrl && created == other.created && email == other.email && familyName == other.familyName && givenName == other.givenName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && id == other.id && avatarUrl == other.avatarUrl && created == other.created && email == other.email && familyName == other.familyName && givenName == other.givenName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -229,6 +263,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "User{id=$id, avatarUrl=$avatarUrl, created=$created, email=$email, familyName=$familyName, givenName=$givenName, additionalProperties=$additionalProperties}" + override fun toString() = "User{id=$id, avatarUrl=$avatarUrl, created=$created, email=$email, familyName=$familyName, givenName=$givenName, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index c02d5269..0c0f286d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.UserService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all users. The users are sorted by creation date, with the most recently-created users - * coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ -class UserListPage -private constructor( +class UserListPage private constructor( private val usersService: UserService, private val params: UserListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserListPage && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is UserListPage && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ - override fun toString() = - "UserListPage{usersService=$usersService, params=$params, response=$response}" + override fun toString() = "UserListPage{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - UserListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - UserListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(UserListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(UserListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { usersService.list(it) } + return getNextPageParams().map { usersService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(usersService: UserService, params: UserListParams, response: Response) = - UserListPage(usersService, params, response) + UserListPage( + usersService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [UserListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: UserListPage) : Iterable { + class AutoPager( + private val firstPage: UserListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 82830d2e..baa4ce20 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.UserServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all users. The users are sorted by creation date, with the most recently-created users - * coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ -class UserListPageAsync -private constructor( +class UserListPageAsync private constructor( private val usersService: UserServiceAsync, private val params: UserListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserListPageAsync && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is UserListPageAsync && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ - override fun toString() = - "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" + override fun toString() = "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - UserListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - UserListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(UserListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(UserListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { usersService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + usersService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(usersService: UserServiceAsync, params: UserListParams, response: Response) = - UserListPageAsync(usersService, params, response) + UserListPageAsync( + usersService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [UserListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: UserListPageAsync) { + class AutoPager( + private val firstPage: UserListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (User) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (User) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index d259099e..be008466 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all users. The users are sorted by creation date, with the most recently-created users - * coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ -class UserListParams -private constructor( +class UserListParams private constructor( private val email: Email?, private val endingBefore: String?, private val familyName: FamilyName?, @@ -38,38 +37,39 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ fun email(): Optional = Optional.ofNullable(email) /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Family name of the user to search for. You may pass the param multiple times to filter for - * more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ fun familyName(): Optional = Optional.ofNullable(familyName) /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ fun givenName(): Optional = Optional.ofNullable(givenName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -82,9 +82,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -95,27 +95,61 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.email?.let { queryParams.put("email", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.familyName?.let { queryParams.put("family_name", listOf(it.toString())) } - this.givenName?.let { queryParams.put("given_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.email?.let { + queryParams.put( + "email", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.familyName?.let { + queryParams.put( + "family_name", listOf(it.toString()) + ) + } + this.givenName?.let { + queryParams.put( + "given_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): UserListParams = builder().build() + @JvmStatic + fun none(): UserListParams = builder().build() /** Returns a mutable builder for constructing an instance of [UserListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [UserListParams]. */ @@ -134,135 +168,154 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(userListParams: UserListParams) = apply { - email = userListParams.email - endingBefore = userListParams.endingBefore - familyName = userListParams.familyName - givenName = userListParams.givenName - ids = userListParams.ids - limit = userListParams.limit - orgName = userListParams.orgName - startingAfter = userListParams.startingAfter - additionalHeaders = userListParams.additionalHeaders.toBuilder() - additionalQueryParams = userListParams.additionalQueryParams.toBuilder() - } + internal fun from(userListParams: UserListParams) = + apply { + email = userListParams.email + endingBefore = userListParams.endingBefore + familyName = userListParams.familyName + givenName = userListParams.givenName + ids = userListParams.ids + limit = userListParams.limit + orgName = userListParams.orgName + startingAfter = userListParams.startingAfter + additionalHeaders = userListParams.additionalHeaders.toBuilder() + additionalQueryParams = userListParams.additionalQueryParams.toBuilder() + } /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ - fun email(email: Email?) = apply { this.email = email } + fun email(email: Email?) = + apply { + this.email = email + } /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ fun email(email: Optional) = email(email.getOrNull()) /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ fun email(string: String) = email(Email.ofString(string)) /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ fun emailOfStrings(strings: List) = email(Email.ofStrings(strings)) /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ - fun familyName(familyName: FamilyName?) = apply { this.familyName = familyName } + fun familyName(familyName: FamilyName?) = + apply { + this.familyName = familyName + } /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ fun familyName(string: String) = familyName(FamilyName.ofString(string)) /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ fun familyNameOfStrings(strings: List) = familyName(FamilyName.ofStrings(strings)) /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ - fun givenName(givenName: GivenName?) = apply { this.givenName = givenName } + fun givenName(givenName: GivenName?) = + apply { + this.givenName = givenName + } /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ fun givenName(string: String) = givenName(GivenName.ofString(string)) /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ fun givenNameOfStrings(strings: List) = givenName(GivenName.ofStrings(strings)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -271,7 +324,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -279,146 +335,174 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): UserListParams = UserListParams( - email, - endingBefore, - familyName, - givenName, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + email, + endingBefore, + familyName, + givenName, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ @JsonDeserialize(using = Email.Deserializer::class) @JsonSerialize(using = Email.Serializer::class) - class Email - private constructor( + class Email private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -436,19 +520,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Email && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Email && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -463,12 +547,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Email(string = string) + @JvmStatic + fun ofString(string: String) = Email(string = string) - @JvmStatic fun ofStrings(strings: List) = Email(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Email(strings = strings) } - /** An interface that defines how to map each variant of [Email] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Email] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -478,62 +567,58 @@ private constructor( /** * Maps an unknown variant of [Email] to a value of type [T]. * - * An instance of [Email] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Email] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Email: $json") + throw BraintrustInvalidDataException("Unknown Email: $json") } } internal class Deserializer : BaseDeserializer(Email::class) { override fun ObjectCodec.deserialize(node: JsonNode): Email { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Email(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Email(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Email(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Email(strings = it, _json = json) + } - return Email(_json = json) + return Email(_json = json) } } internal class Serializer : BaseSerializer(Email::class) { - override fun serialize( - value: Email, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Email") - } + override fun serialize(value: Email, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Email") + } } } } /** - * Family name of the user to search for. You may pass the param multiple times to filter for - * more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ @JsonDeserialize(using = FamilyName.Deserializer::class) @JsonSerialize(using = FamilyName.Serializer::class) - class FamilyName - private constructor( + class FamilyName private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -551,19 +636,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FamilyName && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is FamilyName && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -578,13 +663,16 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = FamilyName(string = string) + @JvmStatic + fun ofString(string: String) = FamilyName(string = string) - @JvmStatic fun ofStrings(strings: List) = FamilyName(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = FamilyName(strings = strings) } /** - * An interface that defines how to map each variant of [FamilyName] to a value of type [T]. + * An interface that defines how to map each variant of [FamilyName] to a value of + * type [T]. */ interface Visitor { @@ -595,62 +683,58 @@ private constructor( /** * Maps an unknown variant of [FamilyName] to a value of type [T]. * - * An instance of [FamilyName] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FamilyName] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FamilyName: $json") + throw BraintrustInvalidDataException("Unknown FamilyName: $json") } } internal class Deserializer : BaseDeserializer(FamilyName::class) { override fun ObjectCodec.deserialize(node: JsonNode): FamilyName { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FamilyName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return FamilyName(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return FamilyName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return FamilyName(strings = it, _json = json) + } - return FamilyName(_json = json) + return FamilyName(_json = json) } } internal class Serializer : BaseSerializer(FamilyName::class) { - override fun serialize( - value: FamilyName, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FamilyName") - } + override fun serialize(value: FamilyName, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FamilyName") + } } } } /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ @JsonDeserialize(using = GivenName.Deserializer::class) @JsonSerialize(using = GivenName.Serializer::class) - class GivenName - private constructor( + class GivenName private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -668,19 +752,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GivenName && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is GivenName && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -695,13 +779,16 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = GivenName(string = string) + @JvmStatic + fun ofString(string: String) = GivenName(string = string) - @JvmStatic fun ofStrings(strings: List) = GivenName(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = GivenName(strings = strings) } /** - * An interface that defines how to map each variant of [GivenName] to a value of type [T]. + * An interface that defines how to map each variant of [GivenName] to a value of + * type [T]. */ interface Visitor { @@ -712,62 +799,58 @@ private constructor( /** * Maps an unknown variant of [GivenName] to a value of type [T]. * - * An instance of [GivenName] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [GivenName] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown GivenName: $json") + throw BraintrustInvalidDataException("Unknown GivenName: $json") } } internal class Deserializer : BaseDeserializer(GivenName::class) { override fun ObjectCodec.deserialize(node: JsonNode): GivenName { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return GivenName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return GivenName(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return GivenName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return GivenName(strings = it, _json = json) + } - return GivenName(_json = json) + return GivenName(_json = json) } } internal class Serializer : BaseSerializer(GivenName::class) { - override fun serialize( - value: GivenName, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid GivenName") - } + override fun serialize(value: GivenName, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid GivenName") + } } } } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -785,19 +868,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -812,12 +895,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -827,60 +915,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserListParams && email == other.email && endingBefore == other.endingBefore && familyName == other.familyName && givenName == other.givenName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is UserListParams && email == other.email && endingBefore == other.endingBefore && familyName == other.familyName && givenName == other.givenName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index b5982ab9..d97040de 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a user object by its id */ -class UserRetrieveParams -private constructor( +class UserRetrieveParams private constructor( private val userId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** User id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> userId - else -> "" - } + return when (index) { + 0 -> userId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,11 +43,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [UserRetrieveParams]. * * The following fields are required: + * * ```java * .userId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [UserRetrieveParams]. */ @@ -59,131 +61,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(userRetrieveParams: UserRetrieveParams) = apply { - userId = userRetrieveParams.userId - additionalHeaders = userRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = userRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(userRetrieveParams: UserRetrieveParams) = + apply { + userId = userRetrieveParams.userId + additionalHeaders = userRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = userRetrieveParams.additionalQueryParams.toBuilder() + } /** User id */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String) = + apply { + this.userId = userId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): UserRetrieveParams = UserRetrieveParams( - checkRequired("userId", userId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "userId", userId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserRetrieveParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is UserRetrieveParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(userId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt index a8bb266f..07910d51 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt @@ -22,36 +22,19 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class View -@JsonCreator -private constructor( +class View @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("view_type") - @ExcludeMissing - private val viewType: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") - @ExcludeMissing - private val viewData: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the view */ @@ -73,8 +56,7 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -86,13 +68,19 @@ private constructor( fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Unique identifier for the view */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -100,10 +88,14 @@ private constructor( fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType + @JsonProperty("view_type") + @ExcludeMissing + fun _viewType(): JsonField = viewType /** Date of view creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -111,13 +103,19 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData + @JsonProperty("view_data") + @ExcludeMissing + fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing @@ -125,23 +123,24 @@ private constructor( private var validated: Boolean = false - fun validate(): View = apply { - if (validated) { - return@apply - } + fun validate(): View = + apply { + if (validated) { + return@apply + } - id() - name() - objectId() - objectType() - viewType() - created() - deletedAt() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - validated = true - } + id() + name() + objectId() + objectType() + viewType() + created() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -151,6 +150,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [View]. * * The following fields are required: + * * ```java * .id() * .name() @@ -159,7 +159,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [View]. */ @@ -178,43 +179,56 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(view: View) = apply { - id = view.id - name = view.name - objectId = view.objectId - objectType = view.objectType - viewType = view.viewType - created = view.created - deletedAt = view.deletedAt - options = view.options - userId = view.userId - viewData = view.viewData - additionalProperties = view.additionalProperties.toMutableMap() - } + internal fun from(view: View) = + apply { + id = view.id + name = view.name + objectId = view.objectId + objectType = view.objectType + viewType = view.viewType + created = view.created + deletedAt = view.deletedAt + options = view.options + userId = view.userId + viewData = view.viewData + additionalProperties = view.additionalProperties.toMutableMap() + } /** Unique identifier for the view */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the view */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) /** Name of the view */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) @@ -223,7 +237,10 @@ private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = + apply { + this.viewType = viewType + } /** Date of view creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -232,7 +249,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of view creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -241,7 +261,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -250,7 +273,10 @@ private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -259,7 +285,10 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -268,55 +297,79 @@ private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + fun viewData(viewData: JsonField) = + apply { + this.viewData = viewData + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): View = View( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - checkRequired("viewType", viewType), - created, - deletedAt, - options, - userId, - viewData, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + checkRequired( + "viewType", viewType + ), + created, + deletedAt, + options, + userId, + viewData, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -364,9 +417,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -382,17 +437,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -413,11 +469,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -438,23 +494,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -463,17 +516,21 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ViewType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -512,9 +569,11 @@ private constructor( * An enum containing [ViewType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ViewType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -526,16 +585,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * An enum member indicating that [ViewType] was instantiated with an unknown + * value. + */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -553,11 +615,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -575,23 +637,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -600,11 +659,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is View && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && created == other.created && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is View && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && created == other.created && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -613,6 +672,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "View{id=$id, name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, created=$created, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = "View{id=$id, name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, created=$created, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt index 0597fc32..0e1d6133 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt @@ -25,14 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new view. If there is an existing view with the same name as the one specified in the - * request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one + * specified in the request, will return the existing view unmodified */ -class ViewCreateParams -private constructor( +class ViewCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the view */ @@ -89,42 +89,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("view_type") - @ExcludeMissing - private val viewType: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") - @ExcludeMissing - private val viewData: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the view */ @@ -140,8 +123,7 @@ private constructor( fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -153,10 +135,14 @@ private constructor( fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -164,7 +150,9 @@ private constructor( fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType + @JsonProperty("view_type") + @ExcludeMissing + fun _viewType(): JsonField = viewType /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -172,13 +160,19 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData + @JsonProperty("view_data") + @ExcludeMissing + fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing @@ -186,22 +180,23 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + viewType() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true } - name() - objectId() - objectType() - viewType() - deletedAt() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -210,6 +205,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .objectId() @@ -217,7 +213,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -234,37 +231,45 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - viewType = body.viewType - deletedAt = body.deletedAt - options = body.options - userId = body.userId - viewData = body.viewData - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + viewType = body.viewType + deletedAt = body.deletedAt + options = body.options + userId = body.userId + viewData = body.viewData + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) /** Name of the view */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) @@ -273,7 +278,10 @@ private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = + apply { + this.viewType = viewType + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -282,9 +290,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -293,7 +302,10 @@ private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -302,7 +314,10 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -311,47 +326,65 @@ private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun viewData(viewData: JsonField) = + apply { + this.viewData = viewData + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - checkRequired("viewType", viewType), - deletedAt, - options, - userId, - viewData, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + checkRequired( + "viewType", viewType + ), + deletedAt, + options, + userId, + viewData, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -360,8 +393,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -372,6 +404,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewCreateParams]. * * The following fields are required: + * * ```java * .name() * .objectId() @@ -379,7 +412,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewCreateParams]. */ @@ -391,208 +425,299 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewCreateParams: ViewCreateParams) = apply { - body = viewCreateParams.body.toBuilder() - additionalHeaders = viewCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = viewCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(viewCreateParams: ViewCreateParams) = + apply { + body = viewCreateParams.body.toBuilder() + additionalHeaders = viewCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewCreateParams.additionalQueryParams.toBuilder() + } /** Name of the view */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the view */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } + fun viewType(viewType: ViewType?) = + apply { + body.viewType(viewType) + } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } + fun viewType(viewType: JsonField) = + apply { + body.viewType(viewType) + } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } + fun deletedAt(deletedAt: OffsetDateTime?) = + apply { + body.deletedAt(deletedAt) + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } + fun deletedAt(deletedAt: JsonField) = + apply { + body.deletedAt(deletedAt) + } /** Options for the view in the app */ - fun options(options: ViewOptions?) = apply { body.options(options) } + fun options(options: ViewOptions?) = + apply { + body.options(options) + } /** Options for the view in the app */ fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { body.options(options) } + fun options(options: JsonField) = + apply { + body.options(options) + } /** Identifies the user who created the view */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** Identifies the user who created the view */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } /** The view definition */ - fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } + fun viewData(viewData: ViewData?) = + apply { + body.viewData(viewData) + } /** The view definition */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } + fun viewData(viewData: JsonField) = + apply { + body.viewData(viewData) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewCreateParams = - ViewCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + ViewCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -640,9 +765,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -658,17 +785,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -689,11 +817,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -714,23 +842,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -739,17 +864,21 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ViewType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -788,9 +917,11 @@ private constructor( * An enum containing [ViewType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ViewType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -802,16 +933,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * An enum member indicating that [ViewType] was instantiated with an unknown + * value. + */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -829,11 +963,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -851,23 +985,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -876,15 +1007,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 70d0d8ce..02851ff5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -19,18 +19,17 @@ import kotlin.jvm.optionals.getOrNull /** The view definition */ @NoAutoDetect -class ViewData -@JsonCreator -private constructor( - @JsonProperty("search") - @ExcludeMissing - private val search: JsonField = JsonMissing.of(), +class ViewData @JsonCreator private constructor( + @JsonProperty("search") @ExcludeMissing private val search: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun search(): Optional = Optional.ofNullable(search.getNullable("search")) - @JsonProperty("search") @ExcludeMissing fun _search(): JsonField = search + @JsonProperty("search") + @ExcludeMissing + fun _search(): JsonField = search @JsonAnyGetter @ExcludeMissing @@ -38,21 +37,23 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewData = apply { - if (validated) { - return@apply - } + fun validate(): ViewData = + apply { + if (validated) { + return@apply + } - search().ifPresent { it.validate() } - validated = true - } + search().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ViewData]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewData]. */ @@ -62,45 +63,59 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewData: ViewData) = apply { - search = viewData.search - additionalProperties = viewData.additionalProperties.toMutableMap() - } + internal fun from(viewData: ViewData) = + apply { + search = viewData.search + additionalProperties = viewData.additionalProperties.toMutableMap() + } fun search(search: ViewDataSearch?) = search(JsonField.ofNullable(search)) fun search(search: Optional) = search(search.getOrNull()) - fun search(search: JsonField) = apply { this.search = search } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ViewData = ViewData(search, additionalProperties.toImmutable()) + fun search(search: JsonField) = + apply { + this.search = search + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): ViewData = + ViewData( + search, additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewData && search == other.search && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewData && search == other.search && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 6d12484b..96cfd4d0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -19,22 +19,13 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ViewDataSearch -@JsonCreator -private constructor( - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField> = JsonMissing.of(), - @JsonProperty("match") - @ExcludeMissing - private val match: JsonField> = JsonMissing.of(), - @JsonProperty("sort") - @ExcludeMissing - private val sort: JsonField> = JsonMissing.of(), - @JsonProperty("tag") - @ExcludeMissing - private val tag: JsonField> = JsonMissing.of(), +class ViewDataSearch @JsonCreator private constructor( + @JsonProperty("filter") @ExcludeMissing private val filter: JsonField> = JsonMissing.of(), + @JsonProperty("match") @ExcludeMissing private val match: JsonField> = JsonMissing.of(), + @JsonProperty("sort") @ExcludeMissing private val sort: JsonField> = JsonMissing.of(), + @JsonProperty("tag") @ExcludeMissing private val tag: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun filter(): Optional> = Optional.ofNullable(filter.getNullable("filter")) @@ -45,13 +36,21 @@ private constructor( fun tag(): Optional> = Optional.ofNullable(tag.getNullable("tag")) - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField> = filter + @JsonProperty("filter") + @ExcludeMissing + fun _filter(): JsonField> = filter - @JsonProperty("match") @ExcludeMissing fun _match(): JsonField> = match + @JsonProperty("match") + @ExcludeMissing + fun _match(): JsonField> = match - @JsonProperty("sort") @ExcludeMissing fun _sort(): JsonField> = sort + @JsonProperty("sort") + @ExcludeMissing + fun _sort(): JsonField> = sort - @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField> = tag + @JsonProperty("tag") + @ExcludeMissing + fun _tag(): JsonField> = tag @JsonAnyGetter @ExcludeMissing @@ -59,24 +58,26 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewDataSearch = apply { - if (validated) { - return@apply + fun validate(): ViewDataSearch = + apply { + if (validated) { + return@apply + } + + filter() + match() + sort() + tag() + validated = true } - filter() - match() - sort() - tag() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ViewDataSearch]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewDataSearch]. */ @@ -89,107 +90,121 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewDataSearch: ViewDataSearch) = apply { - filter = viewDataSearch.filter.map { it.toMutableList() } - match = viewDataSearch.match.map { it.toMutableList() } - sort = viewDataSearch.sort.map { it.toMutableList() } - tag = viewDataSearch.tag.map { it.toMutableList() } - additionalProperties = viewDataSearch.additionalProperties.toMutableMap() - } + internal fun from(viewDataSearch: ViewDataSearch) = + apply { + filter = viewDataSearch.filter.map { it.toMutableList() } + match = viewDataSearch.match.map { it.toMutableList() } + sort = viewDataSearch.sort.map { it.toMutableList() } + tag = viewDataSearch.tag.map { it.toMutableList() } + additionalProperties = viewDataSearch.additionalProperties.toMutableMap() + } fun filter(filter: List?) = filter(JsonField.ofNullable(filter)) fun filter(filter: Optional>) = filter(filter.getOrNull()) - fun filter(filter: JsonField>) = apply { - this.filter = filter.map { it.toMutableList() } - } + fun filter(filter: JsonField>) = + apply { + this.filter = filter.map { it.toMutableList() } + } - fun addFilter(filter: JsonValue) = apply { - this.filter = - (this.filter ?: JsonField.of(mutableListOf())).also { + fun addFilter(filter: JsonValue) = + apply { + this.filter = (this.filter ?: JsonField.of(mutableListOf())).also { checkKnown("filter", it).add(filter) } - } + } fun match(match: List?) = match(JsonField.ofNullable(match)) fun match(match: Optional>) = match(match.getOrNull()) - fun match(match: JsonField>) = apply { - this.match = match.map { it.toMutableList() } - } + fun match(match: JsonField>) = + apply { + this.match = match.map { it.toMutableList() } + } - fun addMatch(match: JsonValue) = apply { - this.match = - (this.match ?: JsonField.of(mutableListOf())).also { + fun addMatch(match: JsonValue) = + apply { + this.match = (this.match ?: JsonField.of(mutableListOf())).also { checkKnown("match", it).add(match) } - } + } fun sort(sort: List?) = sort(JsonField.ofNullable(sort)) fun sort(sort: Optional>) = sort(sort.getOrNull()) - fun sort(sort: JsonField>) = apply { - this.sort = sort.map { it.toMutableList() } - } + fun sort(sort: JsonField>) = + apply { + this.sort = sort.map { it.toMutableList() } + } - fun addSort(sort: JsonValue) = apply { - this.sort = - (this.sort ?: JsonField.of(mutableListOf())).also { + fun addSort(sort: JsonValue) = + apply { + this.sort = (this.sort ?: JsonField.of(mutableListOf())).also { checkKnown("sort", it).add(sort) } - } + } fun tag(tag: List?) = tag(JsonField.ofNullable(tag)) fun tag(tag: Optional>) = tag(tag.getOrNull()) - fun tag(tag: JsonField>) = apply { - this.tag = tag.map { it.toMutableList() } - } + fun tag(tag: JsonField>) = + apply { + this.tag = tag.map { it.toMutableList() } + } - fun addTag(tag: JsonValue) = apply { - this.tag = - (this.tag ?: JsonField.of(mutableListOf())).also { checkKnown("tag", it).add(tag) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: JsonValue) = + apply { + this.tag = (this.tag ?: JsonField.of(mutableListOf())).also { + checkKnown("tag", it).add(tag) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ViewDataSearch = ViewDataSearch( - (filter ?: JsonMissing.of()).map { it.toImmutable() }, - (match ?: JsonMissing.of()).map { it.toImmutable() }, - (sort ?: JsonMissing.of()).map { it.toImmutable() }, - (tag ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (filter ?: JsonMissing.of()).map { it.toImmutable() }, + (match ?: JsonMissing.of()).map { it.toImmutable() }, + (sort ?: JsonMissing.of()).map { it.toImmutable() }, + (tag ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewDataSearch && filter == other.filter && match == other.match && sort == other.sort && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewDataSearch && filter == other.filter && match == other.match && sort == other.sort && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -198,6 +213,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ViewDataSearch{filter=$filter, match=$match, sort=$sort, tag=$tag, additionalProperties=$additionalProperties}" + override fun toString() = "ViewDataSearch{filter=$filter, match=$match, sort=$sort, tag=$tag, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt index fa0585c3..d6cc9336 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt @@ -22,12 +22,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Delete a view object by its id */ -class ViewDeleteParams -private constructor( +class ViewDeleteParams private constructor( private val viewId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** View id */ @@ -51,31 +51,26 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the view applies to */ @@ -85,7 +80,9 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -98,15 +95,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - validated = true - } + objectId() + objectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -116,12 +114,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -132,59 +132,75 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - objectId = body.objectId - objectType = body.objectType - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + objectId = body.objectId + objectType = body.objectType + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -193,8 +209,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = "Body{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -205,13 +220,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewDeleteParams]. * * The following fields are required: + * * ```java * .viewId() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewDeleteParams]. */ @@ -224,166 +241,222 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewDeleteParams: ViewDeleteParams) = apply { - viewId = viewDeleteParams.viewId - body = viewDeleteParams.body.toBuilder() - additionalHeaders = viewDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = viewDeleteParams.additionalQueryParams.toBuilder() - } + internal fun from(viewDeleteParams: ViewDeleteParams) = + apply { + viewId = viewDeleteParams.viewId + body = viewDeleteParams.body.toBuilder() + additionalHeaders = viewDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = viewDeleteParams.additionalQueryParams.toBuilder() + } /** View id */ - fun viewId(viewId: String) = apply { this.viewId = viewId } + fun viewId(viewId: String) = + apply { + this.viewId = viewId + } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewDeleteParams = ViewDeleteParams( - checkRequired("viewId", viewId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "viewId", viewId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -431,9 +504,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -449,17 +524,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -480,11 +556,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -505,23 +581,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -530,15 +603,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewDeleteParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewDeleteParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index fde4f5ac..5ad0e959 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.blocking.ViewService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all views. The views are sorted by creation date, with the most recently-created views - * coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ -class ViewListPage -private constructor( +class ViewListPage private constructor( private val viewsService: ViewService, private val params: ViewListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewListPage && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ViewListPage && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ - override fun toString() = - "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" + override fun toString() = "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ViewListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ViewListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { viewsService.list(it) } + return getNextPageParams().map { viewsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(viewsService: ViewService, params: ViewListParams, response: Response) = - ViewListPage(viewsService, params, response) + ViewListPage( + viewsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ViewListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ViewListPage) : Iterable { + class AutoPager( + private val firstPage: ViewListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index 0a5f58fb..6fec64a6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models import com.braintrustdata.api.services.async.ViewServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all views. The views are sorted by creation date, with the most recently-created views - * coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ -class ViewListPageAsync -private constructor( +class ViewListPageAsync private constructor( private val viewsService: ViewServiceAsync, private val params: ViewListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewListPageAsync && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ViewListPageAsync && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ - override fun toString() = - "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" + override fun toString() = "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ViewListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ViewListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { viewsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + viewsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(viewsService: ViewServiceAsync, params: ViewListParams, response: Response) = - ViewListPageAsync(viewsService, params, response) + ViewListPageAsync( + viewsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ViewListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ViewListPageAsync) { + class AutoPager( + private val firstPage: ViewListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (View) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (View) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt index 3dd24391..dc8f6cda 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt @@ -27,11 +27,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all views. The views are sorted by creation date, with the most recently-created views - * coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ -class ViewListParams -private constructor( +class ViewListParams private constructor( private val objectId: String, private val objectType: ObjectType, private val endingBefore: String?, @@ -42,6 +41,7 @@ private constructor( private val viewType: ViewType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The id of the object the ACL applies to */ @@ -53,15 +53,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -71,9 +71,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -90,17 +90,49 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - this.viewName?.let { queryParams.put("view_name", listOf(it.toString())) } - this.viewType?.let { queryParams.put("view_type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.objectId.let { + queryParams.put( + "object_id", listOf(it.toString()) + ) + } + this.objectType.let { + queryParams.put( + "object_type", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + this.viewName?.let { + queryParams.put( + "view_name", listOf(it.toString()) + ) + } + this.viewType?.let { + queryParams.put( + "view_type", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) @@ -111,12 +143,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewListParams]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewListParams]. */ @@ -135,69 +169,85 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewListParams: ViewListParams) = apply { - objectId = viewListParams.objectId - objectType = viewListParams.objectType - endingBefore = viewListParams.endingBefore - ids = viewListParams.ids - limit = viewListParams.limit - startingAfter = viewListParams.startingAfter - viewName = viewListParams.viewName - viewType = viewListParams.viewType - additionalHeaders = viewListParams.additionalHeaders.toBuilder() - additionalQueryParams = viewListParams.additionalQueryParams.toBuilder() - } + internal fun from(viewListParams: ViewListParams) = + apply { + objectId = viewListParams.objectId + objectType = viewListParams.objectType + endingBefore = viewListParams.endingBefore + ids = viewListParams.ids + limit = viewListParams.limit + startingAfter = viewListParams.startingAfter + viewName = viewListParams.viewName + viewType = viewListParams.viewType + additionalHeaders = viewListParams.additionalHeaders.toBuilder() + additionalQueryParams = viewListParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = + apply { + this.objectType = objectType + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -208,159 +258,201 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) /** Name of the view to search for */ - fun viewName(viewName: String?) = apply { this.viewName = viewName } + fun viewName(viewName: String?) = + apply { + this.viewName = viewName + } /** Name of the view to search for */ fun viewName(viewName: Optional) = viewName(viewName.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType?) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType?) = + apply { + this.viewType = viewType + } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewListParams = ViewListParams( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - endingBefore, - ids, - limit, - startingAfter, - viewName, - viewType, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + endingBefore, + ids, + limit, + startingAfter, + viewName, + viewType, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -408,9 +500,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -426,17 +520,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -457,11 +552,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -482,23 +577,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -507,16 +599,16 @@ private constructor( } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -534,19 +626,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -561,12 +653,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -576,62 +673,63 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ViewType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -670,9 +768,11 @@ private constructor( * An enum containing [ViewType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ViewType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -684,16 +784,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * An enum member indicating that [ViewType] was instantiated with an unknown + * value. + */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -711,11 +814,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -733,23 +836,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -758,15 +858,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && viewName == other.viewName && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && viewName == other.viewName && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 731eab40..c4b9cff4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -20,29 +20,19 @@ import kotlin.jvm.optionals.getOrNull /** Options for the view in the app */ @NoAutoDetect -class ViewOptions -@JsonCreator -private constructor( - @JsonProperty("columnOrder") - @ExcludeMissing - private val columnOrder: JsonField> = JsonMissing.of(), - @JsonProperty("columnSizing") - @ExcludeMissing - private val columnSizing: JsonField = JsonMissing.of(), - @JsonProperty("columnVisibility") - @ExcludeMissing - private val columnVisibility: JsonField = JsonMissing.of(), +class ViewOptions @JsonCreator private constructor( + @JsonProperty("columnOrder") @ExcludeMissing private val columnOrder: JsonField> = JsonMissing.of(), + @JsonProperty("columnSizing") @ExcludeMissing private val columnSizing: JsonField = JsonMissing.of(), + @JsonProperty("columnVisibility") @ExcludeMissing private val columnVisibility: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun columnOrder(): Optional> = - Optional.ofNullable(columnOrder.getNullable("columnOrder")) + fun columnOrder(): Optional> = Optional.ofNullable(columnOrder.getNullable("columnOrder")) - fun columnSizing(): Optional = - Optional.ofNullable(columnSizing.getNullable("columnSizing")) + fun columnSizing(): Optional = Optional.ofNullable(columnSizing.getNullable("columnSizing")) - fun columnVisibility(): Optional = - Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) + fun columnVisibility(): Optional = Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) @JsonProperty("columnOrder") @ExcludeMissing @@ -62,23 +52,25 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewOptions = apply { - if (validated) { - return@apply - } + fun validate(): ViewOptions = + apply { + if (validated) { + return@apply + } - columnOrder() - columnSizing().ifPresent { it.validate() } - columnVisibility().ifPresent { it.validate() } - validated = true - } + columnOrder() + columnSizing().ifPresent { it.validate() } + columnVisibility().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ViewOptions]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewOptions]. */ @@ -90,82 +82,87 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewOptions: ViewOptions) = apply { - columnOrder = viewOptions.columnOrder.map { it.toMutableList() } - columnSizing = viewOptions.columnSizing - columnVisibility = viewOptions.columnVisibility - additionalProperties = viewOptions.additionalProperties.toMutableMap() - } + internal fun from(viewOptions: ViewOptions) = + apply { + columnOrder = viewOptions.columnOrder.map { it.toMutableList() } + columnSizing = viewOptions.columnSizing + columnVisibility = viewOptions.columnVisibility + additionalProperties = viewOptions.additionalProperties.toMutableMap() + } fun columnOrder(columnOrder: List?) = columnOrder(JsonField.ofNullable(columnOrder)) fun columnOrder(columnOrder: Optional>) = columnOrder(columnOrder.getOrNull()) - fun columnOrder(columnOrder: JsonField>) = apply { - this.columnOrder = columnOrder.map { it.toMutableList() } - } + fun columnOrder(columnOrder: JsonField>) = + apply { + this.columnOrder = columnOrder.map { it.toMutableList() } + } - fun addColumnOrder(columnOrder: String) = apply { - this.columnOrder = - (this.columnOrder ?: JsonField.of(mutableListOf())).also { + fun addColumnOrder(columnOrder: String) = + apply { + this.columnOrder = (this.columnOrder ?: JsonField.of(mutableListOf())).also { checkKnown("columnOrder", it).add(columnOrder) } - } + } - fun columnSizing(columnSizing: ColumnSizing?) = - columnSizing(JsonField.ofNullable(columnSizing)) + fun columnSizing(columnSizing: ColumnSizing?) = columnSizing(JsonField.ofNullable(columnSizing)) - fun columnSizing(columnSizing: Optional) = - columnSizing(columnSizing.getOrNull()) + fun columnSizing(columnSizing: Optional) = columnSizing(columnSizing.getOrNull()) - fun columnSizing(columnSizing: JsonField) = apply { - this.columnSizing = columnSizing - } + fun columnSizing(columnSizing: JsonField) = + apply { + this.columnSizing = columnSizing + } - fun columnVisibility(columnVisibility: ColumnVisibility?) = - columnVisibility(JsonField.ofNullable(columnVisibility)) + fun columnVisibility(columnVisibility: ColumnVisibility?) = columnVisibility(JsonField.ofNullable(columnVisibility)) - fun columnVisibility(columnVisibility: Optional) = - columnVisibility(columnVisibility.getOrNull()) + fun columnVisibility(columnVisibility: Optional) = columnVisibility(columnVisibility.getOrNull()) - fun columnVisibility(columnVisibility: JsonField) = apply { - this.columnVisibility = columnVisibility - } + fun columnVisibility(columnVisibility: JsonField) = + apply { + this.columnVisibility = columnVisibility + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ViewOptions = ViewOptions( - (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, - columnSizing, - columnVisibility, - additionalProperties.toImmutable(), + (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, + columnSizing, + columnVisibility, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class ColumnSizing - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class ColumnSizing @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -174,20 +171,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ColumnSizing = apply { - if (validated) { - return@apply - } + fun validate(): ColumnSizing = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ColumnSizing]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ColumnSizing]. */ @@ -196,38 +195,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(columnSizing: ColumnSizing) = apply { - additionalProperties = columnSizing.additionalProperties.toMutableMap() - } + internal fun from(columnSizing: ColumnSizing) = + apply { + additionalProperties = columnSizing.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ColumnSizing = ColumnSizing(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ColumnSizing && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ColumnSizing && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -240,11 +247,9 @@ private constructor( } @NoAutoDetect - class ColumnVisibility - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class ColumnVisibility @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -253,20 +258,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ColumnVisibility = apply { - if (validated) { - return@apply - } + fun validate(): ColumnVisibility = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ColumnVisibility]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ColumnVisibility]. */ @@ -275,38 +282,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(columnVisibility: ColumnVisibility) = apply { - additionalProperties = columnVisibility.additionalProperties.toMutableMap() - } + internal fun from(columnVisibility: ColumnVisibility) = + apply { + additionalProperties = columnVisibility.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ColumnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ColumnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -319,11 +334,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -332,6 +347,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, additionalProperties=$additionalProperties}" + override fun toString() = "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt index d99f4f94..a6b1c015 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt @@ -25,14 +25,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace view. If there is an existing view with the same name as the one specified in - * the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the + * one specified in the request, will replace the existing view with the provided + * fields */ -class ViewReplaceParams -private constructor( +class ViewReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the view */ @@ -89,42 +90,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("view_type") - @ExcludeMissing - private val viewType: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") - @ExcludeMissing - private val viewData: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the view */ @@ -140,8 +124,7 @@ private constructor( fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -153,10 +136,14 @@ private constructor( fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -164,7 +151,9 @@ private constructor( fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType + @JsonProperty("view_type") + @ExcludeMissing + fun _viewType(): JsonField = viewType /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -172,13 +161,19 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData + @JsonProperty("view_data") + @ExcludeMissing + fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing @@ -186,22 +181,23 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + viewType() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true } - name() - objectId() - objectType() - viewType() - deletedAt() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -210,6 +206,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .objectId() @@ -217,7 +214,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -234,37 +232,45 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - viewType = body.viewType - deletedAt = body.deletedAt - options = body.options - userId = body.userId - viewData = body.viewData - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + viewType = body.viewType + deletedAt = body.deletedAt + options = body.options + userId = body.userId + viewData = body.viewData + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) /** Name of the view */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) @@ -273,7 +279,10 @@ private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = + apply { + this.viewType = viewType + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -282,9 +291,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -293,7 +303,10 @@ private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -302,7 +315,10 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -311,47 +327,65 @@ private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun viewData(viewData: JsonField) = + apply { + this.viewData = viewData + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - checkRequired("viewType", viewType), - deletedAt, - options, - userId, - viewData, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + checkRequired( + "viewType", viewType + ), + deletedAt, + options, + userId, + viewData, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -360,8 +394,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -372,6 +405,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewReplaceParams]. * * The following fields are required: + * * ```java * .name() * .objectId() @@ -379,7 +413,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewReplaceParams]. */ @@ -391,212 +426,299 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewReplaceParams: ViewReplaceParams) = apply { - body = viewReplaceParams.body.toBuilder() - additionalHeaders = viewReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = viewReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(viewReplaceParams: ViewReplaceParams) = + apply { + body = viewReplaceParams.body.toBuilder() + additionalHeaders = viewReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = viewReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the view */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the view */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } + fun viewType(viewType: ViewType?) = + apply { + body.viewType(viewType) + } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } + fun viewType(viewType: JsonField) = + apply { + body.viewType(viewType) + } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } + fun deletedAt(deletedAt: OffsetDateTime?) = + apply { + body.deletedAt(deletedAt) + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } + fun deletedAt(deletedAt: JsonField) = + apply { + body.deletedAt(deletedAt) + } /** Options for the view in the app */ - fun options(options: ViewOptions?) = apply { body.options(options) } + fun options(options: ViewOptions?) = + apply { + body.options(options) + } /** Options for the view in the app */ fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { body.options(options) } + fun options(options: JsonField) = + apply { + body.options(options) + } /** Identifies the user who created the view */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** Identifies the user who created the view */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } /** The view definition */ - fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } + fun viewData(viewData: ViewData?) = + apply { + body.viewData(viewData) + } /** The view definition */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } + fun viewData(viewData: JsonField) = + apply { + body.viewData(viewData) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewReplaceParams = ViewReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -644,9 +766,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -662,17 +786,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -693,11 +818,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -718,23 +843,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -743,17 +865,21 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ViewType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -792,9 +918,11 @@ private constructor( * An enum containing [ViewType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ViewType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -806,16 +934,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * An enum member indicating that [ViewType] was instantiated with an unknown + * value. + */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -833,11 +964,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -855,23 +986,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -880,15 +1008,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt index 84f0af7c..4b814372 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt @@ -14,13 +14,13 @@ import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects /** Get a view object by its id */ -class ViewRetrieveParams -private constructor( +class ViewRetrieveParams private constructor( private val viewId: String, private val objectId: String, private val objectType: ObjectType, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** View id */ @@ -39,18 +39,26 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.objectId.let { + queryParams.put( + "object_id", listOf(it.toString()) + ) + } + this.objectType.let { + queryParams.put( + "object_type", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -61,13 +69,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewRetrieveParams]. * * The following fields are required: + * * ```java * .viewId() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewRetrieveParams]. */ @@ -81,143 +91,189 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewRetrieveParams: ViewRetrieveParams) = apply { - viewId = viewRetrieveParams.viewId - objectId = viewRetrieveParams.objectId - objectType = viewRetrieveParams.objectType - additionalHeaders = viewRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = viewRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(viewRetrieveParams: ViewRetrieveParams) = + apply { + viewId = viewRetrieveParams.viewId + objectId = viewRetrieveParams.objectId + objectType = viewRetrieveParams.objectType + additionalHeaders = viewRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = viewRetrieveParams.additionalQueryParams.toBuilder() + } /** View id */ - fun viewId(viewId: String) = apply { this.viewId = viewId } + fun viewId(viewId: String) = + apply { + this.viewId = viewId + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = + apply { + this.objectType = objectType + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewRetrieveParams = ViewRetrieveParams( - checkRequired("viewId", viewId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "viewId", viewId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -265,9 +321,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -283,17 +341,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -314,11 +373,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -339,23 +398,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -364,15 +420,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewRetrieveParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewRetrieveParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt index 368c4698..de7d0da8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt @@ -24,16 +24,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ -class ViewUpdateParams -private constructor( +class ViewUpdateParams private constructor( private val viewId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** View id */ @@ -87,46 +87,31 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") - @ExcludeMissing - private val viewData: JsonField = JsonMissing.of(), - @JsonProperty("view_type") - @ExcludeMissing - private val viewType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), + @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the view applies to */ @@ -151,7 +136,9 @@ private constructor( fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -159,19 +146,29 @@ private constructor( fun _objectType(): JsonField = objectType /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData + @JsonProperty("view_data") + @ExcludeMissing + fun _viewData(): JsonField = viewData /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType + @JsonProperty("view_type") + @ExcludeMissing + fun _viewType(): JsonField = viewType @JsonAnyGetter @ExcludeMissing @@ -179,21 +176,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + objectId() + objectType() + name() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + viewType() + validated = true } - objectId() - objectType() - name() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - viewType() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -202,12 +200,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -223,30 +223,35 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - objectId = body.objectId - objectType = body.objectType - name = body.name - options = body.options - userId = body.userId - viewData = body.viewData - viewType = body.viewType - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + objectId = body.objectId + objectType = body.objectType + name = body.name + options = body.options + userId = body.userId + viewData = body.viewData + viewType = body.viewType + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** Name of the view */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -255,7 +260,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the view */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -264,7 +272,10 @@ private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -273,7 +284,10 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -282,7 +296,10 @@ private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + fun viewData(viewData: JsonField) = + apply { + this.viewData = viewData + } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) @@ -291,46 +308,60 @@ private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun viewType(viewType: JsonField) = + apply { + this.viewType = viewType + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - name, - options, - userId, - viewData, - viewType, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + name, + options, + userId, + viewData, + viewType, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -339,8 +370,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" + override fun toString() = "Body{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -351,13 +381,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewUpdateParams]. * * The following fields are required: + * * ```java * .viewId() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewUpdateParams]. */ @@ -370,211 +402,297 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewUpdateParams: ViewUpdateParams) = apply { - viewId = viewUpdateParams.viewId - body = viewUpdateParams.body.toBuilder() - additionalHeaders = viewUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = viewUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(viewUpdateParams: ViewUpdateParams) = + apply { + viewId = viewUpdateParams.viewId + body = viewUpdateParams.body.toBuilder() + additionalHeaders = viewUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewUpdateParams.additionalQueryParams.toBuilder() + } /** View id */ - fun viewId(viewId: String) = apply { this.viewId = viewId } + fun viewId(viewId: String) = + apply { + this.viewId = viewId + } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } /** Name of the view */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the view */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the view */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Options for the view in the app */ - fun options(options: ViewOptions?) = apply { body.options(options) } + fun options(options: ViewOptions?) = + apply { + body.options(options) + } /** Options for the view in the app */ fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { body.options(options) } + fun options(options: JsonField) = + apply { + body.options(options) + } /** Identifies the user who created the view */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** Identifies the user who created the view */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } /** The view definition */ - fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } + fun viewData(viewData: ViewData?) = + apply { + body.viewData(viewData) + } /** The view definition */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } + fun viewData(viewData: JsonField) = + apply { + body.viewData(viewData) + } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } + fun viewType(viewType: ViewType?) = + apply { + body.viewType(viewType) + } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } + fun viewType(viewType: JsonField) = + apply { + body.viewType(viewType) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewUpdateParams = ViewUpdateParams( - checkRequired("viewId", viewId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "viewId", viewId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -622,9 +740,11 @@ private constructor( * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -640,17 +760,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -671,11 +792,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -696,23 +817,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -721,17 +839,21 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + class ViewType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -770,9 +892,11 @@ private constructor( * An enum containing [ViewType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ViewType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -784,16 +908,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * An enum member indicating that [ViewType] was instantiated with an unknown + * value. + */ _UNKNOWN, } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ fun value(): Value = when (this) { @@ -811,11 +938,11 @@ private constructor( /** * Returns an enum member corresponding to this class instance's value. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -833,23 +960,20 @@ private constructor( /** * Returns this class instance's primitive wire representation. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -858,15 +982,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewUpdateParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewUpdateParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index 5138c220..0c4146d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -19,89 +19,85 @@ import java.util.concurrent.CompletableFuture interface AclServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one + * specified in the request, will return the existing acl unmodified */ fun create(params: AclCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: AclCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an acl object by its id */ fun retrieve(params: AclRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ fun list(params: AclListParams): CompletableFuture = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list( - params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Delete an acl object by its id */ fun delete(params: AclDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. + * Batch update acls. This operation is idempotent, so adding acls which already + * exist will have no effect, and removing acls which do not exist will have no + * effect. */ - fun batchUpdate(): CompletableFuture = - batchUpdate(AclBatchUpdateParams.none()) + fun batchUpdate(): CompletableFuture = batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): CompletableFuture = batchUpdate(params, RequestOptions.none()) + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): CompletableFuture = + batchUpdate( + params, RequestOptions.none() + ) /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ - fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [AclServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [AclServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -110,29 +106,27 @@ interface AclServiceAsync { */ @MustBeClosed fun create(params: AclCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: AclCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as - * [AclServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the + * same as [AclServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: AclRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as @@ -140,58 +134,49 @@ interface AclServiceAsync { */ @MustBeClosed fun list(params: AclListParams): CompletableFuture> = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as - * [AclServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the + * same as [AclServiceAsync.delete]. */ @MustBeClosed fun delete(params: AclDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclServiceAsync.batchUpdate]. + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise + * the same as [AclServiceAsync.batchUpdate]. */ @MustBeClosed - fun batchUpdate(): CompletableFuture> = - batchUpdate(AclBatchUpdateParams.none()) + fun batchUpdate(): CompletableFuture> = batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): CompletableFuture> = - batchUpdate(params, RequestOptions.none()) + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): CompletableFuture> = + batchUpdate( + params, RequestOptions.none() + ) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - requestOptions: RequestOptions - ): CompletableFuture> = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): CompletableFuture> = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as @@ -199,13 +184,12 @@ interface AclServiceAsync { */ @MustBeClosed fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture> = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index e99ec877..841e0d36 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -21,248 +21,201 @@ import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams +import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListPageAsync import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams import java.util.concurrent.CompletableFuture -class AclServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - AclServiceAsync { +class AclServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: AclServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : AclServiceAsync { + + private val withRawResponse: AclServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): AclServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: AclCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: AclCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/acl withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/acl/{acl_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list( - params: AclListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: AclListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/acl withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/acl/batch-update withRawResponse().batchUpdate(params, requestOptions).thenApply { it.parse() } - override fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/acl withRawResponse().findAndDelete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AclServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : AclServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: AclCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: AclCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: AclListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - AclListPageAsync.of(AclServiceAsyncImpl(clientOptions), params, it) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: AclListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AclListPageAsync.of(AclServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val batchUpdateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch-update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + batchUpdateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + findAndDeleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt index dc90a38c..9e8a0053 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt @@ -19,225 +19,204 @@ import java.util.concurrent.CompletableFuture interface AiSecretServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will return the existing ai_secret unmodified + * Create a new ai_secret. If there is an existing ai_secret with the same name as + * the one specified in the request, will return the existing ai_secret unmodified */ fun create(params: AiSecretCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an ai_secret object by its id */ fun retrieve(params: AiSecretRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update an ai_secret object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an ai_secret object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: AiSecretUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ fun list(): CompletableFuture = list(AiSecretListParams.none()) /** @see [list] */ - fun list( - params: AiSecretListParams = AiSecretListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: AiSecretListParams = AiSecretListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: AiSecretListParams = AiSecretListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(AiSecretListParams.none(), requestOptions) /** Delete an ai_secret object by its id */ fun delete(params: AiSecretDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Delete a single ai_secret */ fun findAndDelete(params: AiSecretFindAndDeleteParams): CompletableFuture = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ - fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will replace the existing ai_secret with the provided fields + * Create or replace ai_secret. If there is an existing ai_secret with the same + * name as the one specified in the request, will replace the existing ai_secret + * with the provided fields */ fun replace(params: AiSecretReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [AiSecretServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [AiSecretServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as - * [AiSecretServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same + * as [AiSecretServiceAsync.create]. */ @MustBeClosed fun create(params: AiSecretCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the - * same as [AiSecretServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: AiSecretRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise - * the same as [AiSecretServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretServiceAsync.update]. */ @MustBeClosed fun update(params: AiSecretUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as - * [AiSecretServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same + * as [AiSecretServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(AiSecretListParams.none()) + fun list(): CompletableFuture> = list(AiSecretListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: AiSecretListParams = AiSecretListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: AiSecretListParams = AiSecretListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: AiSecretListParams = AiSecretListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(AiSecretListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise - * the same as [AiSecretServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretServiceAsync.delete]. */ @MustBeClosed fun delete(params: AiSecretDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as - * [AiSecretServiceAsync.findAndDelete]. + * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the + * same as [AiSecretServiceAsync.findAndDelete]. */ @MustBeClosed - fun findAndDelete( - params: AiSecretFindAndDeleteParams - ): CompletableFuture> = - findAndDelete(params, RequestOptions.none()) + fun findAndDelete(params: AiSecretFindAndDeleteParams): CompletableFuture> = + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as - * [AiSecretServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same + * as [AiSecretServiceAsync.replace]. */ @MustBeClosed fun replace(params: AiSecretReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index fbe03e82..92f11347 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.braintrustdata.api.models.AISecret import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams +import com.braintrustdata.api.models.AiSecretListPage import com.braintrustdata.api.models.AiSecretListPageAsync import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams @@ -26,283 +27,224 @@ import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams import java.util.concurrent.CompletableFuture -class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - AiSecretServiceAsync { +class AiSecretServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: AiSecretServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : AiSecretServiceAsync { + + private val withRawResponse: AiSecretServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): AiSecretServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/ai_secret withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/ai_secret/{ai_secret_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/ai_secret/{ai_secret_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: AiSecretListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: AiSecretListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/ai_secret withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/ai_secret/{ai_secret_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/ai_secret withRawResponse().findAndDelete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/ai_secret withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AiSecretServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : AiSecretServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: AiSecretListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - AiSecretListPageAsync.of( - AiSecretServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: AiSecretListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AiSecretListPageAsync.of(AiSecretServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + findAndDeleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index 94e69910..efa0446f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -17,32 +17,31 @@ import java.util.concurrent.CompletableFuture interface ApiKeyServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is - * no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same + * name. There is no de-duplication */ fun create(params: ApiKeyCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an api_key object by its id */ fun retrieve(params: ApiKeyRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all api_keys. The api_keys are sorted by creation date, with the most @@ -51,32 +50,29 @@ interface ApiKeyServiceAsync { fun list(): CompletableFuture = list(ApiKeyListParams.none()) /** @see [list] */ - fun list( - params: ApiKeyListParams = ApiKeyListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ApiKeyListParams = ApiKeyListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ApiKeyListParams = ApiKeyListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ApiKeyListParams.none(), requestOptions) /** Delete an api_key object by its id */ fun delete(params: ApiKeyDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ApiKeyServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [ApiKeyServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -85,75 +81,63 @@ interface ApiKeyServiceAsync { * [ApiKeyServiceAsync.create]. */ @MustBeClosed - fun create( - params: ApiKeyCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) + fun create(params: ApiKeyCreateParams): CompletableFuture> = + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same - * as [ApiKeyServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise + * the same as [ApiKeyServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: ApiKeyRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as * [ApiKeyServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ApiKeyListParams.none()) + fun list(): CompletableFuture> = list(ApiKeyListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ApiKeyListParams = ApiKeyListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ApiKeyListParams = ApiKeyListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ApiKeyListParams = ApiKeyListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ApiKeyListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the - * same as [ApiKeyServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is + * otherwise the same as [ApiKeyServiceAsync.delete]. */ @MustBeClosed fun delete(params: ApiKeyDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index ca00a3e4..8bc1a341 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -18,178 +18,144 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams +import com.braintrustdata.api.models.ApiKeyListPage import com.braintrustdata.api.models.ApiKeyListPageAsync import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput import java.util.concurrent.CompletableFuture -class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ApiKeyServiceAsync { +class ApiKeyServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ApiKeyServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ApiKeyServiceAsync { + + private val withRawResponse: ApiKeyServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ApiKeyServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/api_key withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/api_key/{api_key_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ApiKeyListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/api_key withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/api_key/{api_key_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ApiKeyServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ApiKeyServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ApiKeyListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ApiKeyListPageAsync.of( - ApiKeyServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ApiKeyListPageAsync.of(ApiKeyServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index a6d7c52c..9e33a36b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -26,46 +26,45 @@ import java.util.concurrent.CompletableFuture interface DatasetServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified + * Create a new dataset. If there is an existing dataset in the project with the + * same name as the one specified in the request, will return the existing dataset + * unmodified */ fun create(params: DatasetCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a dataset object by its id */ fun retrieve(params: DatasetRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a dataset object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: DatasetUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all datasets. The datasets are sorted by creation date, with the most @@ -74,90 +73,82 @@ interface DatasetServiceAsync { fun list(): CompletableFuture = list(DatasetListParams.none()) /** @see [list] */ - fun list( - params: DatasetListParams = DatasetListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: DatasetListParams = DatasetListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: DatasetListParams = DatasetListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(DatasetListParams.none(), requestOptions) /** Delete a dataset object by its id */ fun delete(params: DatasetDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Log feedback for a set of dataset events */ fun feedback(params: DatasetFeedbackParams): CompletableFuture = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but + * with the parameters in the URL query rather than in the request body. For more + * complex queries, use the `POST /btql` endpoint. */ fun fetch(params: DatasetFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but + * with the parameters in the request body rather than in the URL query. For more + * complex queries, use the `POST /btql` endpoint. */ fun fetchPost(params: DatasetFetchPostParams): CompletableFuture = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Insert a set of events into the dataset */ fun insert(params: DatasetInsertParams): CompletableFuture = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Summarize dataset */ fun summarize(params: DatasetSummarizeParams): CompletableFuture = - summarize(params, RequestOptions.none()) + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ - fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -167,172 +158,146 @@ interface DatasetServiceAsync { */ @MustBeClosed fun create(params: DatasetCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same - * as [DatasetServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise + * the same as [DatasetServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: DatasetRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the - * same as [DatasetServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is + * otherwise the same as [DatasetServiceAsync.update]. */ @MustBeClosed fun update(params: DatasetUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as * [DatasetServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(DatasetListParams.none()) + fun list(): CompletableFuture> = list(DatasetListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: DatasetListParams = DatasetListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: DatasetListParams = DatasetListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: DatasetListParams = DatasetListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(DatasetListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the - * same as [DatasetServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is + * otherwise the same as [DatasetServiceAsync.delete]. */ @MustBeClosed fun delete(params: DatasetDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is * otherwise the same as [DatasetServiceAsync.feedback]. */ @MustBeClosed - fun feedback( - params: DatasetFeedbackParams - ): CompletableFuture> = - feedback(params, RequestOptions.none()) + fun feedback(params: DatasetFeedbackParams): CompletableFuture> = + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise - * the same as [DatasetServiceAsync.fetch]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is + * otherwise the same as [DatasetServiceAsync.fetch]. */ @MustBeClosed - fun fetch( - params: DatasetFetchParams - ): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(params: DatasetFetchParams): CompletableFuture> = + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise - * the same as [DatasetServiceAsync.fetchPost]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is + * otherwise the same as [DatasetServiceAsync.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: DatasetFetchPostParams - ): CompletableFuture> = - fetchPost(params, RequestOptions.none()) + fun fetchPost(params: DatasetFetchPostParams): CompletableFuture> = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise - * the same as [DatasetServiceAsync.insert]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is + * otherwise the same as [DatasetServiceAsync.insert]. */ @MustBeClosed - fun insert( - params: DatasetInsertParams - ): CompletableFuture> = - insert(params, RequestOptions.none()) + fun insert(params: DatasetInsertParams): CompletableFuture> = + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is * otherwise the same as [DatasetServiceAsync.summarize]. */ @MustBeClosed - fun summarize( - params: DatasetSummarizeParams - ): CompletableFuture> = - summarize(params, RequestOptions.none()) + fun summarize(params: DatasetSummarizeParams): CompletableFuture> = + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ @MustBeClosed - fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index 7a5002f9..3b020629 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -22,6 +22,7 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams +import com.braintrustdata.api.models.DatasetListPage import com.braintrustdata.api.models.DatasetListPageAsync import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams @@ -33,397 +34,309 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse import java.util.concurrent.CompletableFuture -class DatasetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - DatasetServiceAsync { +class DatasetServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : DatasetServiceAsync { + + private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): DatasetServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/dataset withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/dataset/{dataset_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/dataset/{dataset_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: DatasetListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: DatasetListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/dataset withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/dataset/{dataset_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/dataset/{dataset_id}/feedback withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - override fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/dataset/{dataset_id}/fetch withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - override fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/dataset/{dataset_id}/fetch withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - override fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/dataset/{dataset_id}/insert withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - override fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/dataset/{dataset_id}/summarize withRawResponse().summarize(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DatasetServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : DatasetServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: DatasetListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - DatasetListPageAsync.of( - DatasetServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: DatasetListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DatasetListPageAsync.of(DatasetServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + summarizeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt index 49a3693f..628a4047 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt @@ -18,46 +18,44 @@ import java.util.concurrent.CompletableFuture interface EnvVarServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new env_var. If there is an existing env_var with the same name as the one specified - * in the request, will return the existing env_var unmodified + * Create a new env_var. If there is an existing env_var with the same name as the + * one specified in the request, will return the existing env_var unmodified */ fun create(params: EnvVarCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an env_var object by its id */ fun retrieve(params: EnvVarRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update an env_var object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an env_var object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: EnvVarUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all env_vars. The env_vars are sorted by creation date, with the most @@ -66,45 +64,42 @@ interface EnvVarServiceAsync { fun list(): CompletableFuture = list(EnvVarListParams.none()) /** @see [list] */ - fun list( - params: EnvVarListParams = EnvVarListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: EnvVarListParams = EnvVarListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: EnvVarListParams = EnvVarListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(EnvVarListParams.none(), requestOptions) /** Delete an env_var object by its id */ fun delete(params: EnvVarDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace env_var. If there is an existing env_var with the same name as the one - * specified in the request, will replace the existing env_var with the provided fields + * Create or replace env_var. If there is an existing env_var with the same name as + * the one specified in the request, will replace the existing env_var with the + * provided fields */ fun replace(params: EnvVarReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [EnvVarServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [EnvVarServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -114,88 +109,77 @@ interface EnvVarServiceAsync { */ @MustBeClosed fun create(params: EnvVarCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same - * as [EnvVarServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise + * the same as [EnvVarServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: EnvVarRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the - * same as [EnvVarServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is + * otherwise the same as [EnvVarServiceAsync.update]. */ @MustBeClosed fun update(params: EnvVarUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as * [EnvVarServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(EnvVarListParams.none()) + fun list(): CompletableFuture> = list(EnvVarListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: EnvVarListParams = EnvVarListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: EnvVarListParams = EnvVarListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: EnvVarListParams = EnvVarListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(EnvVarListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the - * same as [EnvVarServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is + * otherwise the same as [EnvVarServiceAsync.delete]. */ @MustBeClosed fun delete(params: EnvVarDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as @@ -203,13 +187,12 @@ interface EnvVarServiceAsync { */ @MustBeClosed fun replace(params: EnvVarReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index c4ed7f35..e2f36b30 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -25,238 +25,192 @@ import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams import java.util.concurrent.CompletableFuture -class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - EnvVarServiceAsync { +class EnvVarServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: EnvVarServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : EnvVarServiceAsync { + + private val withRawResponse: EnvVarServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): EnvVarServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/env_var withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/env_var/{env_var_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/env_var/{env_var_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: EnvVarListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: EnvVarListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/env_var withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/env_var/{env_var_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/env_var withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - EnvVarServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : EnvVarServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list( - params: EnvVarListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: EnvVarListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt index 69b6f45c..8d84a6a7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt @@ -12,27 +12,31 @@ import java.util.concurrent.CompletableFuture interface EvalServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into - * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and - * scoring functions. The API will then run the evaluation, create an experiment, and return the - * results along with a link to the experiment. To learn more about evals, see the + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is + * built into the Braintrust SDK. In the Eval API, you provide pointers to a + * dataset, task function, and scoring functions. The API will then run the + * evaluation, create an experiment, and return the results along with a link to + * the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ fun create(params: EvalCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [EvalServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [EvalServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -40,16 +44,13 @@ interface EvalServiceAsync { * [EvalServiceAsync.create]. */ @MustBeClosed - fun create( - params: EvalCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) + fun create(params: EvalCreateParams): CompletableFuture> = + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index d0fc0019..8a578fb7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -19,56 +19,49 @@ import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture -class EvalServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - EvalServiceAsync { +class EvalServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: EvalServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : EvalServiceAsync { + + private val withRawResponse: EvalServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): EvalServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: EvalCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: EvalCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/eval withRawResponse().create(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - EvalServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : EvalServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun create( - params: EvalCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "eval") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + override fun create(params: EvalCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "eval") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index e10046e6..b49f1978 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -26,317 +26,278 @@ import java.util.concurrent.CompletableFuture interface ExperimentServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new experiment. If there is an existing experiment in the project with the same name - * as the one specified in the request, will return the existing experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with + * the same name as the one specified in the request, will return the existing + * experiment unmodified */ fun create(params: ExperimentCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an experiment object by its id */ fun retrieve(params: ExperimentRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: ExperimentUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ fun list(): CompletableFuture = list(ExperimentListParams.none()) /** @see [list] */ - fun list( - params: ExperimentListParams = ExperimentListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ExperimentListParams = ExperimentListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ExperimentListParams = ExperimentListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ExperimentListParams.none(), requestOptions) /** Delete an experiment object by its id */ fun delete(params: ExperimentDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Log feedback for a set of experiment events */ fun feedback(params: ExperimentFeedbackParams): CompletableFuture = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the POST form of the same path, + * but with the parameters in the URL query rather than in the request body. For + * more complex queries, use the `POST /btql` endpoint. */ fun fetch(params: ExperimentFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ - fun fetchPost( - params: ExperimentFetchPostParams - ): CompletableFuture = fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ExperimentFetchPostParams): CompletableFuture = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Insert a set of events into the experiment */ fun insert(params: ExperimentInsertParams): CompletableFuture = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Summarize experiment */ - fun summarize( - params: ExperimentSummarizeParams - ): CompletableFuture = summarize(params, RequestOptions.none()) + fun summarize(params: ExperimentSummarizeParams): CompletableFuture = + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ - fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ExperimentServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [ExperimentServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as - * [ExperimentServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same + * as [ExperimentServiceAsync.create]. */ @MustBeClosed fun create(params: ExperimentCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: ExperimentRetrieveParams - ): CompletableFuture> = retrieve(params, RequestOptions.none()) + fun retrieve(params: ExperimentRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentServiceAsync.update]. */ @MustBeClosed fun update(params: ExperimentUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as - * [ExperimentServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same + * as [ExperimentServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ExperimentListParams.none()) + fun list(): CompletableFuture> = list(ExperimentListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ExperimentListParams = ExperimentListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ExperimentListParams = ExperimentListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ExperimentListParams = ExperimentListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ExperimentListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentServiceAsync.delete]. */ @MustBeClosed fun delete(params: ExperimentDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is - * otherwise the same as [ExperimentServiceAsync.feedback]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, + * but is otherwise the same as [ExperimentServiceAsync.feedback]. */ @MustBeClosed - fun feedback( - params: ExperimentFeedbackParams - ): CompletableFuture> = - feedback(params, RequestOptions.none()) + fun feedback(params: ExperimentFeedbackParams): CompletableFuture> = + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is - * otherwise the same as [ExperimentServiceAsync.fetch]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but + * is otherwise the same as [ExperimentServiceAsync.fetch]. */ @MustBeClosed - fun fetch( - params: ExperimentFetchParams - ): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(params: ExperimentFetchParams): CompletableFuture> = + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is - * otherwise the same as [ExperimentServiceAsync.fetchPost]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but + * is otherwise the same as [ExperimentServiceAsync.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: ExperimentFetchPostParams - ): CompletableFuture> = - fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ExperimentFetchPostParams): CompletableFuture> = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is - * otherwise the same as [ExperimentServiceAsync.insert]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, + * but is otherwise the same as [ExperimentServiceAsync.insert]. */ @MustBeClosed - fun insert( - params: ExperimentInsertParams - ): CompletableFuture> = - insert(params, RequestOptions.none()) + fun insert(params: ExperimentInsertParams): CompletableFuture> = + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is - * otherwise the same as [ExperimentServiceAsync.summarize]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, + * but is otherwise the same as [ExperimentServiceAsync.summarize]. */ @MustBeClosed - fun summarize( - params: ExperimentSummarizeParams - ): CompletableFuture> = - summarize(params, RequestOptions.none()) + fun summarize(params: ExperimentSummarizeParams): CompletableFuture> = + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ @MustBeClosed - fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 432baacd..0c92d8b0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -22,6 +22,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -33,397 +34,309 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture -class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ExperimentServiceAsync { +class ExperimentServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ExperimentServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ExperimentServiceAsync { + + private val withRawResponse: ExperimentServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ExperimentServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/experiment withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/experiment/{experiment_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/experiment/{experiment_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ExperimentListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ExperimentListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/experiment withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/experiment/{experiment_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/experiment/{experiment_id}/feedback withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - override fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/experiment/{experiment_id}/fetch withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - override fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/experiment/{experiment_id}/fetch withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - override fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/experiment/{experiment_id}/insert withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - override fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/experiment/{experiment_id}/summarize withRawResponse().summarize(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ExperimentServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ExperimentServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ExperimentListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ExperimentListPageAsync.of( - ExperimentServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ExperimentListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ExperimentListPageAsync.of(ExperimentServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + summarizeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index b625969e..89865299 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -21,46 +21,45 @@ import java.util.concurrent.CompletableFuture interface FunctionServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified + * Create a new function. If there is an existing function in the project with the + * same slug as the one specified in the request, will return the existing function + * unmodified */ fun create(params: FunctionCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a function object by its id */ fun retrieve(params: FunctionRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a function object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: FunctionUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all functions. The functions are sorted by creation date, with the most @@ -69,164 +68,145 @@ interface FunctionServiceAsync { fun list(): CompletableFuture = list(FunctionListParams.none()) /** @see [list] */ - fun list( - params: FunctionListParams = FunctionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: FunctionListParams = FunctionListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: FunctionListParams = FunctionListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(FunctionListParams.none(), requestOptions) /** Delete a function object by its id */ fun delete(params: FunctionDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Invoke a function. */ fun invoke(params: FunctionInvokeParams): CompletableFuture> = - invoke(params, RequestOptions.none()) + invoke( + params, RequestOptions.none() + ) /** @see [invoke] */ - fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Create or replace function. If there is an existing function in the project with the same - * slug as the one specified in the request, will replace the existing function with the - * provided fields + * Create or replace function. If there is an existing function in the project with + * the same slug as the one specified in the request, will replace the existing + * function with the provided fields */ fun replace(params: FunctionReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [FunctionServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [FunctionServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as - * [FunctionServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same + * as [FunctionServiceAsync.create]. */ @MustBeClosed fun create(params: FunctionCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the - * same as [FunctionServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is + * otherwise the same as [FunctionServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: FunctionRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the - * same as [FunctionServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is + * otherwise the same as [FunctionServiceAsync.update]. */ @MustBeClosed fun update(params: FunctionUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as * [FunctionServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(FunctionListParams.none()) + fun list(): CompletableFuture> = list(FunctionListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: FunctionListParams = FunctionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: FunctionListParams = FunctionListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: FunctionListParams = FunctionListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(FunctionListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the - * same as [FunctionServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is + * otherwise the same as [FunctionServiceAsync.delete]. */ @MustBeClosed fun delete(params: FunctionDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is * otherwise the same as [FunctionServiceAsync.invoke]. */ @MustBeClosed - fun invoke( - params: FunctionInvokeParams - ): CompletableFuture>> = - invoke(params, RequestOptions.none()) + fun invoke(params: FunctionInvokeParams): CompletableFuture>> = + invoke( + params, RequestOptions.none() + ) /** @see [invoke] */ @MustBeClosed - fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture>> /** * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as @@ -234,13 +214,12 @@ interface FunctionServiceAsync { */ @MustBeClosed fun replace(params: FunctionReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 27377950..09c07695 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams import com.braintrustdata.api.models.FunctionInvokeResponse +import com.braintrustdata.api.models.FunctionListPage import com.braintrustdata.api.models.FunctionListPageAsync import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams @@ -28,284 +29,224 @@ import com.braintrustdata.api.models.FunctionUpdateParams import java.util.Optional import java.util.concurrent.CompletableFuture -class FunctionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - FunctionServiceAsync { +class FunctionServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: FunctionServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : FunctionServiceAsync { + + private val withRawResponse: FunctionServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): FunctionServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/function withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/function/{function_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/function/{function_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: FunctionListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: FunctionListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/function withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/function/{function_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions, - ): CompletableFuture> = + override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): CompletableFuture> = // post /v1/function/{function_id}/invoke withRawResponse().invoke(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/function withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - FunctionServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : FunctionServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: FunctionListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - FunctionListPageAsync.of( - FunctionServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: FunctionListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + FunctionListPageAsync.of(FunctionServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val invokeHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions, - ): CompletableFuture>> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { invokeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } - } - } - } - } + private val invokeHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): CompletableFuture>> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function", params.getPathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + invokeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt index 9c172789..04d7d5b7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt @@ -18,92 +18,89 @@ import java.util.concurrent.CompletableFuture interface GroupServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one + * specified in the request, will return the existing group unmodified */ fun create(params: GroupCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a group object by its id */ fun retrieve(params: GroupRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: GroupUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ fun list(): CompletableFuture = list(GroupListParams.none()) /** @see [list] */ - fun list( - params: GroupListParams = GroupListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: GroupListParams = GroupListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: GroupListParams = GroupListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(GroupListParams.none(), requestOptions) /** Delete a group object by its id */ fun delete(params: GroupDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace group. If there is an existing group with the same name as the one - * specified in the request, will replace the existing group with the provided fields + * Create or replace group. If there is an existing group with the same name as the + * one specified in the request, will replace the existing group with the provided + * fields */ fun replace(params: GroupReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [GroupServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [GroupServiceAsync] that provides access to raw HTTP responses for + * each method. + */ interface WithRawResponse { /** @@ -112,88 +109,77 @@ interface GroupServiceAsync { */ @MustBeClosed fun create(params: GroupCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as - * [GroupServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the + * same as [GroupServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: GroupRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same - * as [GroupServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise + * the same as [GroupServiceAsync.update]. */ @MustBeClosed fun update(params: GroupUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as * [GroupServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(GroupListParams.none()) + fun list(): CompletableFuture> = list(GroupListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: GroupListParams = GroupListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: GroupListParams = GroupListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: GroupListParams = GroupListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(GroupListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same - * as [GroupServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise + * the same as [GroupServiceAsync.delete]. */ @MustBeClosed fun delete(params: GroupDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as @@ -201,13 +187,12 @@ interface GroupServiceAsync { */ @MustBeClosed fun replace(params: GroupReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index db541802..7400ac18 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams +import com.braintrustdata.api.models.GroupListPage import com.braintrustdata.api.models.GroupListPageAsync import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams import java.util.concurrent.CompletableFuture -class GroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - GroupServiceAsync { +class GroupServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: GroupServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : GroupServiceAsync { + + private val withRawResponse: GroupServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): GroupServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: GroupCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: GroupCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/group withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/group/{group_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/group/{group_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: GroupListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: GroupListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/group withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/group/{group_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/group withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - GroupServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : GroupServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: GroupCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: GroupCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: GroupListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - GroupListPageAsync.of( - GroupServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: GroupListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + GroupListPageAsync.of(GroupServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt index a224dbd9..42e1be2c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt @@ -17,7 +17,8 @@ import java.util.concurrent.CompletableFuture interface OrganizationServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -25,62 +26,56 @@ interface OrganizationServiceAsync { /** Get an organization object by its id */ fun retrieve(params: OrganizationRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update an organization object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an organization object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: OrganizationUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ fun list(): CompletableFuture = list(OrganizationListParams.none()) /** @see [list] */ - fun list( - params: OrganizationListParams = OrganizationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: OrganizationListParams = OrganizationListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: OrganizationListParams = OrganizationListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(OrganizationListParams.none(), requestOptions) /** Delete an organization object by its id */ fun delete(params: OrganizationDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [OrganizationServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [OrganizationServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { @@ -91,77 +86,63 @@ interface OrganizationServiceAsync { * otherwise the same as [OrganizationServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: OrganizationRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + fun retrieve(params: OrganizationRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is - * otherwise the same as [OrganizationServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but + * is otherwise the same as [OrganizationServiceAsync.update]. */ @MustBeClosed - fun update( - params: OrganizationUpdateParams - ): CompletableFuture> = update(params, RequestOptions.none()) + fun update(params: OrganizationUpdateParams): CompletableFuture> = + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as - * [OrganizationServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the + * same as [OrganizationServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(OrganizationListParams.none()) + fun list(): CompletableFuture> = list(OrganizationListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: OrganizationListParams = OrganizationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: OrganizationListParams = OrganizationListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: OrganizationListParams = OrganizationListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(OrganizationListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is - * otherwise the same as [OrganizationServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but + * is otherwise the same as [OrganizationServiceAsync.delete]. */ @MustBeClosed - fun delete( - params: OrganizationDeleteParams - ): CompletableFuture> = delete(params, RequestOptions.none()) + fun delete(params: OrganizationDeleteParams): CompletableFuture> = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 08667293..959bb5c4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams +import com.braintrustdata.api.models.OrganizationListPage import com.braintrustdata.api.models.OrganizationListPageAsync import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams @@ -25,12 +26,12 @@ import com.braintrustdata.api.services.async.organizations.MemberServiceAsync import com.braintrustdata.api.services.async.organizations.MemberServiceAsyncImpl import java.util.concurrent.CompletableFuture -class OrganizationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - OrganizationServiceAsync { +class OrganizationServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: OrganizationServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : OrganizationServiceAsync { + + private val withRawResponse: OrganizationServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } private val members: MemberServiceAsync by lazy { MemberServiceAsyncImpl(clientOptions) } @@ -38,169 +39,132 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption override fun members(): MemberServiceAsync = members - override fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/organization/{organization_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/organization/{organization_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: OrganizationListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: OrganizationListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/organization withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/organization/{organization_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - OrganizationServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : OrganizationServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val members: MemberServiceAsync.WithRawResponse by lazy { - MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val members: MemberServiceAsync.WithRawResponse by lazy { MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) } override fun members(): MemberServiceAsync.WithRawResponse = members - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: OrganizationListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - OrganizationListPageAsync.of( - OrganizationServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: OrganizationListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + OrganizationListPageAsync.of(OrganizationServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt index beca7a59..aa644b97 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt @@ -18,207 +18,182 @@ import java.util.concurrent.CompletableFuture interface ProjectScoreServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_score. If there is an existing project_score in the project with the - * same name as the one specified in the request, will return the existing project_score - * unmodified + * Create a new project_score. If there is an existing project_score in the project + * with the same name as the one specified in the request, will return the existing + * project_score unmodified */ fun create(params: ProjectScoreCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a project_score object by its id */ fun retrieve(params: ProjectScoreRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: ProjectScoreUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ fun list(): CompletableFuture = list(ProjectScoreListParams.none()) /** @see [list] */ - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectScoreListParams.none(), requestOptions) /** Delete a project_score object by its id */ fun delete(params: ProjectScoreDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace project_score. If there is an existing project_score in the project with - * the same name as the one specified in the request, will replace the existing project_score - * with the provided fields + * Create or replace project_score. If there is an existing project_score in the + * project with the same name as the one specified in the request, will replace the + * existing project_score with the provided fields */ fun replace(params: ProjectScoreReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ProjectScoreServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [ProjectScoreServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as - * [ProjectScoreServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the + * same as [ProjectScoreServiceAsync.create]. */ @MustBeClosed - fun create( - params: ProjectScoreCreateParams - ): CompletableFuture> = create(params, RequestOptions.none()) + fun create(params: ProjectScoreCreateParams): CompletableFuture> = + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but + * is otherwise the same as [ProjectScoreServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: ProjectScoreRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + fun retrieve(params: ProjectScoreRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, + * but is otherwise the same as [ProjectScoreServiceAsync.update]. */ @MustBeClosed - fun update( - params: ProjectScoreUpdateParams - ): CompletableFuture> = update(params, RequestOptions.none()) + fun update(params: ProjectScoreUpdateParams): CompletableFuture> = + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as - * [ProjectScoreServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the + * same as [ProjectScoreServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ProjectScoreListParams.none()) + fun list(): CompletableFuture> = list(ProjectScoreListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ProjectScoreListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, + * but is otherwise the same as [ProjectScoreServiceAsync.delete]. */ @MustBeClosed - fun delete( - params: ProjectScoreDeleteParams - ): CompletableFuture> = delete(params, RequestOptions.none()) + fun delete(params: ProjectScoreDeleteParams): CompletableFuture> = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as - * [ProjectScoreServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the + * same as [ProjectScoreServiceAsync.replace]. */ @MustBeClosed - fun replace( - params: ProjectScoreReplaceParams - ): CompletableFuture> = replace(params, RequestOptions.none()) + fun replace(params: ProjectScoreReplaceParams): CompletableFuture> = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index cde96d23..1f2c575c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams +import com.braintrustdata.api.models.ProjectScoreListPage import com.braintrustdata.api.models.ProjectScoreListPageAsync import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams import java.util.concurrent.CompletableFuture -class ProjectScoreServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectScoreServiceAsync { +class ProjectScoreServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectScoreServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectScoreServiceAsync { + + private val withRawResponse: ProjectScoreServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ProjectScoreServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_score withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_score/{project_score_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/project_score/{project_score_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_score withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/project_score/{project_score_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/project_score withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectScoreServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : ProjectScoreServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectScoreListPageAsync.of( - ProjectScoreServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectScoreListPageAsync.of(ProjectScoreServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt index c1c67326..150a37a6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt @@ -18,48 +18,46 @@ import java.util.concurrent.CompletableFuture interface ProjectServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse fun logs(): LogServiceAsync /** - * Create a new project. If there is an existing project with the same name as the one specified - * in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the + * one specified in the request, will return the existing project unmodified */ fun create(params: ProjectCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a project object by its id */ fun retrieve(params: ProjectRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a project object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: ProjectUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all projects. The projects are sorted by creation date, with the most @@ -68,32 +66,29 @@ interface ProjectServiceAsync { fun list(): CompletableFuture = list(ProjectListParams.none()) /** @see [list] */ - fun list( - params: ProjectListParams = ProjectListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ProjectListParams = ProjectListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ProjectListParams = ProjectListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectListParams.none(), requestOptions) /** Delete a project object by its id */ fun delete(params: ProjectDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ProjectServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [ProjectServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -105,87 +100,76 @@ interface ProjectServiceAsync { */ @MustBeClosed fun create(params: ProjectCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same - * as [ProjectServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise + * the same as [ProjectServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the - * same as [ProjectServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is + * otherwise the same as [ProjectServiceAsync.update]. */ @MustBeClosed fun update(params: ProjectUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as * [ProjectServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ProjectListParams.none()) + fun list(): CompletableFuture> = list(ProjectListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectListParams = ProjectListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ProjectListParams = ProjectListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ProjectListParams = ProjectListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ProjectListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the - * same as [ProjectServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is + * otherwise the same as [ProjectServiceAsync.delete]. */ @MustBeClosed fun delete(params: ProjectDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index dba161a5..53bb7b05 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams +import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListPageAsync import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams @@ -26,12 +27,12 @@ import com.braintrustdata.api.services.async.projects.LogServiceAsync import com.braintrustdata.api.services.async.projects.LogServiceAsyncImpl import java.util.concurrent.CompletableFuture -class ProjectServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectServiceAsync { +class ProjectServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectServiceAsync { + + private val withRawResponse: ProjectServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } private val logs: LogServiceAsync by lazy { LogServiceAsyncImpl(clientOptions) } @@ -39,206 +40,161 @@ class ProjectServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun logs(): LogServiceAsync = logs - override fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project/{project_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/project/{project_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ProjectListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ProjectListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/project/{project_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ProjectServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val logs: LogServiceAsync.WithRawResponse by lazy { - LogServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val logs: LogServiceAsync.WithRawResponse by lazy { LogServiceAsyncImpl.WithRawResponseImpl(clientOptions) } override fun logs(): LogServiceAsync.WithRawResponse = logs - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectListPageAsync.of( - ProjectServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectListPageAsync.of(ProjectServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt index 6d681309..7a823a70 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt @@ -18,128 +18,119 @@ import java.util.concurrent.CompletableFuture interface ProjectTagServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will return the existing project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project + * with the same name as the one specified in the request, will return the existing + * project_tag unmodified */ fun create(params: ProjectTagCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a project_tag object by its id */ fun retrieve(params: ProjectTagRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: ProjectTagUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ fun list(): CompletableFuture = list(ProjectTagListParams.none()) /** @see [list] */ - fun list( - params: ProjectTagListParams = ProjectTagListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ProjectTagListParams = ProjectTagListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ProjectTagListParams = ProjectTagListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectTagListParams.none(), requestOptions) /** Delete a project_tag object by its id */ fun delete(params: ProjectTagDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace project_tag. If there is an existing project_tag in the project with the - * same name as the one specified in the request, will replace the existing project_tag with the - * provided fields + * Create or replace project_tag. If there is an existing project_tag in the + * project with the same name as the one specified in the request, will replace the + * existing project_tag with the provided fields */ fun replace(params: ProjectTagReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ProjectTagServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [ProjectTagServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as - * [ProjectTagServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the + * same as [ProjectTagServiceAsync.create]. */ @MustBeClosed fun create(params: ProjectTagCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise - * the same as [ProjectTagServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: ProjectTagRetrieveParams - ): CompletableFuture> = retrieve(params, RequestOptions.none()) + fun retrieve(params: ProjectTagRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is @@ -147,73 +138,62 @@ interface ProjectTagServiceAsync { */ @MustBeClosed fun update(params: ProjectTagUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as - * [ProjectTagServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same + * as [ProjectTagServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ProjectTagListParams.none()) + fun list(): CompletableFuture> = list(ProjectTagListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectTagListParams = ProjectTagListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ProjectTagListParams = ProjectTagListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ProjectTagListParams = ProjectTagListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ProjectTagListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is - * otherwise the same as [ProjectTagServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but + * is otherwise the same as [ProjectTagServiceAsync.delete]. */ @MustBeClosed fun delete(params: ProjectTagDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as - * [ProjectTagServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same + * as [ProjectTagServiceAsync.replace]. */ @MustBeClosed - fun replace( - params: ProjectTagReplaceParams - ): CompletableFuture> = replace(params, RequestOptions.none()) + fun replace(params: ProjectTagReplaceParams): CompletableFuture> = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index d12a821a..21850a9d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams +import com.braintrustdata.api.models.ProjectTagListPage import com.braintrustdata.api.models.ProjectTagListPageAsync import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams import java.util.concurrent.CompletableFuture -class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectTagServiceAsync { +class ProjectTagServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectTagServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectTagServiceAsync { + + private val withRawResponse: ProjectTagServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ProjectTagServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_tag withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_tag/{project_tag_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/project_tag/{project_tag_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_tag withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/project_tag/{project_tag_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/project_tag withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectTagServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : ProjectTagServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectTagListPageAsync.of( - ProjectTagServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectTagListPageAsync.of(ProjectTagServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt index afb7a900..9a962e3b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt @@ -18,93 +18,89 @@ import java.util.concurrent.CompletableFuture interface PromptServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified + * Create a new prompt. If there is an existing prompt in the project with the same + * slug as the one specified in the request, will return the existing prompt + * unmodified */ fun create(params: PromptCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a prompt object by its id */ fun retrieve(params: PromptRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a prompt object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: PromptUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ fun list(): CompletableFuture = list(PromptListParams.none()) /** @see [list] */ - fun list( - params: PromptListParams = PromptListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: PromptListParams = PromptListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: PromptListParams = PromptListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(PromptListParams.none(), requestOptions) /** Delete a prompt object by its id */ fun delete(params: PromptDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as - * the one specified in the request, will replace the existing prompt with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the + * same slug as the one specified in the request, will replace the existing prompt + * with the provided fields */ fun replace(params: PromptReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [PromptServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [PromptServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -114,88 +110,77 @@ interface PromptServiceAsync { */ @MustBeClosed fun create(params: PromptCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same - * as [PromptServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise + * the same as [PromptServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: PromptRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same - * as [PromptServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise + * the same as [PromptServiceAsync.update]. */ @MustBeClosed fun update(params: PromptUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as * [PromptServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(PromptListParams.none()) + fun list(): CompletableFuture> = list(PromptListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: PromptListParams = PromptListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: PromptListParams = PromptListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: PromptListParams = PromptListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(PromptListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the - * same as [PromptServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is + * otherwise the same as [PromptServiceAsync.delete]. */ @MustBeClosed fun delete(params: PromptDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as @@ -203,13 +188,12 @@ interface PromptServiceAsync { */ @MustBeClosed fun replace(params: PromptReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index 7772aa68..3a65157b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams +import com.braintrustdata.api.models.PromptListPage import com.braintrustdata.api.models.PromptListPageAsync import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams import java.util.concurrent.CompletableFuture -class PromptServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - PromptServiceAsync { +class PromptServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: PromptServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : PromptServiceAsync { + + private val withRawResponse: PromptServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): PromptServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: PromptCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: PromptCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/prompt withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/prompt/{prompt_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/prompt/{prompt_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: PromptListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: PromptListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/prompt withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/prompt/{prompt_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/prompt withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - PromptServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : PromptServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: PromptCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: PromptCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: PromptListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - PromptListPageAsync.of( - PromptServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: PromptListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + PromptListPageAsync.of(PromptServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt index 988acc47..4dc148d9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt @@ -18,91 +18,89 @@ import java.util.concurrent.CompletableFuture interface RoleServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one + * specified in the request, will return the existing role unmodified */ fun create(params: RoleCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a role object by its id */ fun retrieve(params: RoleRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ fun update(params: RoleUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all roles. The roles are sorted by creation date, with the most recently-created - * roles coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ fun list(): CompletableFuture = list(RoleListParams.none()) /** @see [list] */ - fun list( - params: RoleListParams = RoleListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ fun list(params: RoleListParams = RoleListParams.none()): CompletableFuture = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(RoleListParams.none(), requestOptions) /** Delete a role object by its id */ fun delete(params: RoleDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace role. If there is an existing role with the same name as the one specified - * in the request, will replace the existing role with the provided fields + * Create or replace role. If there is an existing role with the same name as the + * one specified in the request, will replace the existing role with the provided + * fields */ fun replace(params: RoleReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [RoleServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [RoleServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -111,88 +109,77 @@ interface RoleServiceAsync { */ @MustBeClosed fun create(params: RoleCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as - * [RoleServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the + * same as [RoleServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: RoleRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as - * [RoleServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the + * same as [RoleServiceAsync.update]. */ @MustBeClosed fun update(params: RoleUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as * [RoleServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(RoleListParams.none()) + fun list(): CompletableFuture> = list(RoleListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: RoleListParams = RoleListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: RoleListParams = RoleListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: RoleListParams = RoleListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(RoleListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as - * [RoleServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise + * the same as [RoleServiceAsync.delete]. */ @MustBeClosed fun delete(params: RoleDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as @@ -200,13 +187,12 @@ interface RoleServiceAsync { */ @MustBeClosed fun replace(params: RoleReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index f4809686..dec426f5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams +import com.braintrustdata.api.models.RoleListPage import com.braintrustdata.api.models.RoleListPageAsync import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams import java.util.concurrent.CompletableFuture -class RoleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - RoleServiceAsync { +class RoleServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: RoleServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : RoleServiceAsync { + + private val withRawResponse: RoleServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): RoleServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: RoleCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: RoleCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/role withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/role/{role_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/role/{role_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: RoleListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: RoleListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/role withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/role/{role_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/role withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - RoleServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : RoleServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: RoleCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: RoleCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: RoleListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - RoleListPageAsync.of( - RoleServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: RoleListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + RoleListPageAsync.of(RoleServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt index 442357ea..fce4db78 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt @@ -18,127 +18,119 @@ import java.util.concurrent.CompletableFuture interface SpanIframeServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will return the existing span_iframe unmodified + * Create a new span_iframe. If there is an existing span_iframe with the same name + * as the one specified in the request, will return the existing span_iframe + * unmodified */ fun create(params: SpanIframeCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a span_iframe object by its id */ fun retrieve(params: SpanIframeRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a span_iframe object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a span_iframe object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: SpanIframeUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ fun list(): CompletableFuture = list(SpanIframeListParams.none()) /** @see [list] */ - fun list( - params: SpanIframeListParams = SpanIframeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: SpanIframeListParams = SpanIframeListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: SpanIframeListParams = SpanIframeListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(SpanIframeListParams.none(), requestOptions) /** Delete a span_iframe object by its id */ fun delete(params: SpanIframeDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace span_iframe. If there is an existing span_iframe with the same name as the - * one specified in the request, will replace the existing span_iframe with the provided fields + * Create or replace span_iframe. If there is an existing span_iframe with the same + * name as the one specified in the request, will replace the existing span_iframe + * with the provided fields */ fun replace(params: SpanIframeReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [SpanIframeServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [SpanIframeServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as - * [SpanIframeServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the + * same as [SpanIframeServiceAsync.create]. */ @MustBeClosed fun create(params: SpanIframeCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise - * the same as [SpanIframeServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: SpanIframeRetrieveParams - ): CompletableFuture> = retrieve(params, RequestOptions.none()) + fun retrieve(params: SpanIframeRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is @@ -146,73 +138,62 @@ interface SpanIframeServiceAsync { */ @MustBeClosed fun update(params: SpanIframeUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as - * [SpanIframeServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same + * as [SpanIframeServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(SpanIframeListParams.none()) + fun list(): CompletableFuture> = list(SpanIframeListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: SpanIframeListParams = SpanIframeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: SpanIframeListParams = SpanIframeListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: SpanIframeListParams = SpanIframeListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(SpanIframeListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is - * otherwise the same as [SpanIframeServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but + * is otherwise the same as [SpanIframeServiceAsync.delete]. */ @MustBeClosed fun delete(params: SpanIframeDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as - * [SpanIframeServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same + * as [SpanIframeServiceAsync.replace]. */ @MustBeClosed - fun replace( - params: SpanIframeReplaceParams - ): CompletableFuture> = replace(params, RequestOptions.none()) + fun replace(params: SpanIframeReplaceParams): CompletableFuture> = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt index 6dd3a6b3..c8752694 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.SpanIFrame import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListPage import com.braintrustdata.api.models.SpanIframeListPageAsync import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams import java.util.concurrent.CompletableFuture -class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - SpanIframeServiceAsync { +class SpanIframeServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: SpanIframeServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : SpanIframeServiceAsync { + + private val withRawResponse: SpanIframeServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): SpanIframeServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/span_iframe withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/span_iframe/{span_iframe_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/span_iframe/{span_iframe_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: SpanIframeListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/span_iframe withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/span_iframe/{span_iframe_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/span_iframe withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - SpanIframeServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : SpanIframeServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: SpanIframeListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - SpanIframeListPageAsync.of( - SpanIframeServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SpanIframeListPageAsync.of(SpanIframeServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt index 5411c270..8f17d844 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt @@ -11,30 +11,32 @@ import java.util.concurrent.CompletableFuture interface TopLevelServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + /** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ fun helloWorld(): CompletableFuture = helloWorld(TopLevelHelloWorldParams.none()) /** @see [helloWorld] */ - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [helloWorld] */ - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() - ): CompletableFuture = helloWorld(params, RequestOptions.none()) + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): CompletableFuture = + helloWorld( + params, RequestOptions.none() + ) /** @see [helloWorld] */ - fun helloWorld(requestOptions: RequestOptions): CompletableFuture = - helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): CompletableFuture = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) /** - * A view of [TopLevelServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [TopLevelServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -43,25 +45,21 @@ interface TopLevelServiceAsync { * [TopLevelServiceAsync.helloWorld]. */ @MustBeClosed - fun helloWorld(): CompletableFuture> = - helloWorld(TopLevelHelloWorldParams.none()) + fun helloWorld(): CompletableFuture> = helloWorld(TopLevelHelloWorldParams.none()) /** @see [helloWorld] */ @MustBeClosed - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [helloWorld] */ @MustBeClosed - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() - ): CompletableFuture> = helloWorld(params, RequestOptions.none()) + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): CompletableFuture> = + helloWorld( + params, RequestOptions.none() + ) /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(requestOptions: RequestOptions): CompletableFuture> = - helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): CompletableFuture> = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index efc7d4ce..49f348d0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -17,46 +17,43 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams import java.util.concurrent.CompletableFuture -class TopLevelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - TopLevelServiceAsync { +class TopLevelServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: TopLevelServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : TopLevelServiceAsync { + + private val withRawResponse: TopLevelServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): TopLevelServiceAsync.WithRawResponse = withRawResponse - override fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): CompletableFuture = // get /v1 withRawResponse().helloWorld(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TopLevelServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : TopLevelServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = - stringHandler().withErrorHandler(errorHandler) - - override fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { response.use { helloWorldHandler.handle(it) } } - } + private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) + + override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + helloWorldHandler.handle(it) + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt index 2bf974c5..274de7e7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt @@ -14,85 +14,78 @@ import java.util.concurrent.CompletableFuture interface UserServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Get a user object by its id */ fun retrieve(params: UserRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all users. The users are sorted by creation date, with the most recently-created - * users coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ fun list(): CompletableFuture = list(UserListParams.none()) /** @see [list] */ - fun list( - params: UserListParams = UserListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ fun list(params: UserListParams = UserListParams.none()): CompletableFuture = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(UserListParams.none(), requestOptions) - /** A view of [UserServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [UserServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as - * [UserServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the + * same as [UserServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: UserRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as * [UserServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(UserListParams.none()) + fun list(): CompletableFuture> = list(UserListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: UserListParams = UserListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: UserListParams = UserListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: UserListParams = UserListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(UserListParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 54c73c41..3041b017 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -15,103 +15,85 @@ import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.User +import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListPageAsync import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import java.util.concurrent.CompletableFuture -class UserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - UserServiceAsync { +class UserServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : UserServiceAsync { + + private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): UserServiceAsync.WithRawResponse = withRawResponse - override fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/user/{user_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list( - params: UserListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: UserListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/user withRawResponse().list(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - UserServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : UserServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun list( - params: UserListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - UserListPageAsync.of( - UserServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + override fun list(params: UserListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + UserListPageAsync.of(UserServiceAsyncImpl(clientOptions), params, it) + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt index f70248e9..8134d5a3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt @@ -18,84 +18,83 @@ import java.util.concurrent.CompletableFuture interface ViewServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one + * specified in the request, will return the existing view unmodified */ fun create(params: ViewCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a view object by its id */ fun retrieve(params: ViewRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ fun update(params: ViewUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all views. The views are sorted by creation date, with the most recently-created - * views coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ fun list(params: ViewListParams): CompletableFuture = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list( - params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Delete a view object by its id */ fun delete(params: ViewDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace view. If there is an existing view with the same name as the one specified - * in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the + * one specified in the request, will replace the existing view with the provided + * fields */ fun replace(params: ViewReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [ViewServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ViewServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -104,44 +103,41 @@ interface ViewServiceAsync { */ @MustBeClosed fun create(params: ViewCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as - * [ViewServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the + * same as [ViewServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: ViewRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as - * [ViewServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the + * same as [ViewServiceAsync.update]. */ @MustBeClosed fun update(params: ViewUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as @@ -149,29 +145,27 @@ interface ViewServiceAsync { */ @MustBeClosed fun list(params: ViewListParams): CompletableFuture> = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as - * [ViewServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise + * the same as [ViewServiceAsync.delete]. */ @MustBeClosed fun delete(params: ViewDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as @@ -179,13 +173,12 @@ interface ViewServiceAsync { */ @MustBeClosed fun replace(params: ViewReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index 644bd149..2da433b4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams +import com.braintrustdata.api.models.ViewListPage import com.braintrustdata.api.models.ViewListPageAsync import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams import java.util.concurrent.CompletableFuture -class ViewServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ViewServiceAsync { +class ViewServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ViewServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ViewServiceAsync { + + private val withRawResponse: ViewServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ViewServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ViewCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ViewCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/view withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/view/{view_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/view/{view_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ViewListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ViewListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/view withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/view/{view_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/view withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ViewServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : ViewServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: ViewCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ViewCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ViewListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ViewListPageAsync.of( - ViewServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ViewListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ViewListPageAsync.of(ViewServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt index 78042415..e27990ac 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt @@ -12,61 +12,52 @@ import java.util.concurrent.CompletableFuture interface MemberServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Modify organization membership */ - fun update(): CompletableFuture = - update(OrganizationMemberUpdateParams.none()) + fun update(): CompletableFuture = update(OrganizationMemberUpdateParams.none()) /** @see [update] */ - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [update] */ - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() - ): CompletableFuture = update(params, RequestOptions.none()) + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): CompletableFuture = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update(requestOptions: RequestOptions): CompletableFuture = - update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): CompletableFuture = update(OrganizationMemberUpdateParams.none(), requestOptions) /** - * A view of [MemberServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [MemberServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the - * same as [MemberServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/organization/members`, but is + * otherwise the same as [MemberServiceAsync.update]. */ @MustBeClosed - fun update(): CompletableFuture> = - update(OrganizationMemberUpdateParams.none()) + fun update(): CompletableFuture> = update(OrganizationMemberUpdateParams.none()) /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() - ): CompletableFuture> = - update(params, RequestOptions.none()) + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): CompletableFuture> = + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - requestOptions: RequestOptions - ): CompletableFuture> = - update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): CompletableFuture> = update(OrganizationMemberUpdateParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index ac1cca4a..82c4ff17 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -19,56 +19,49 @@ import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput import java.util.concurrent.CompletableFuture -class MemberServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - MemberServiceAsync { +class MemberServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : MemberServiceAsync { + + private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): MemberServiceAsync.WithRawResponse = withRawResponse - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/organization/members withRawResponse().update(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - MemberServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : MemberServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index b1d19e58..1b67edf9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -17,128 +17,115 @@ import java.util.concurrent.CompletableFuture interface LogServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Log feedback for a set of project logs events */ fun feedback(params: ProjectLogFeedbackParams): CompletableFuture = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the POST form of the same + * path, but with the parameters in the URL query rather than in the request body. + * For more complex queries, use the `POST /btql` endpoint. */ fun fetch(params: ProjectLogFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ - fun fetchPost( - params: ProjectLogFetchPostParams - ): CompletableFuture = fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ProjectLogFetchPostParams): CompletableFuture = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Insert a set of events into the project logs */ fun insert(params: ProjectLogInsertParams): CompletableFuture = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [LogServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [LogServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is - * otherwise the same as [LogServiceAsync.feedback]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, + * but is otherwise the same as [LogServiceAsync.feedback]. */ @MustBeClosed - fun feedback( - params: ProjectLogFeedbackParams - ): CompletableFuture> = - feedback(params, RequestOptions.none()) + fun feedback(params: ProjectLogFeedbackParams): CompletableFuture> = + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is - * otherwise the same as [LogServiceAsync.fetch]. + * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but + * is otherwise the same as [LogServiceAsync.fetch]. */ @MustBeClosed - fun fetch( - params: ProjectLogFetchParams - ): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(params: ProjectLogFetchParams): CompletableFuture> = + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is - * otherwise the same as [LogServiceAsync.fetchPost]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but + * is otherwise the same as [LogServiceAsync.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: ProjectLogFetchPostParams - ): CompletableFuture> = - fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ProjectLogFetchPostParams): CompletableFuture> = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is - * otherwise the same as [LogServiceAsync.insert]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but + * is otherwise the same as [LogServiceAsync.insert]. */ @MustBeClosed - fun insert( - params: ProjectLogInsertParams - ): CompletableFuture> = - insert(params, RequestOptions.none()) + fun insert(params: ProjectLogInsertParams): CompletableFuture> = + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index 7c47266f..abb30573 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -24,169 +24,135 @@ import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams import java.util.concurrent.CompletableFuture -class LogServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - LogServiceAsync { +class LogServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: LogServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : LogServiceAsync { + + private val withRawResponse: LogServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): LogServiceAsync.WithRawResponse = withRawResponse - override fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_logs/{project_id}/feedback withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_logs/{project_id}/fetch withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_logs/{project_id}/fetch withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_logs/{project_id}/insert withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - LogServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : LogServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index 5d4a4de6..70828f20 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -18,78 +18,85 @@ import com.google.errorprone.annotations.MustBeClosed interface AclService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one + * specified in the request, will return the existing acl unmodified */ - fun create(params: AclCreateParams): Acl = create(params, RequestOptions.none()) + fun create(params: AclCreateParams): Acl = + create( + params, RequestOptions.none() + ) /** @see [create] */ fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** Get an acl object by its id */ - fun retrieve(params: AclRetrieveParams): Acl = retrieve(params, RequestOptions.none()) + fun retrieve(params: AclRetrieveParams): Acl = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Acl + fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ - fun list(params: AclListParams): AclListPage = list(params, RequestOptions.none()) + fun list(params: AclListParams): AclListPage = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list( - params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AclListPage + fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): AclListPage /** Delete an acl object by its id */ - fun delete(params: AclDeleteParams): Acl = delete(params, RequestOptions.none()) + fun delete(params: AclDeleteParams): Acl = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. + * Batch update acls. This operation is idempotent, so adding acls which already + * exist will have no effect, and removing acls which do not exist will have no + * effect. */ fun batchUpdate(): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AclBatchUpdateResponse + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): AclBatchUpdateResponse /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): AclBatchUpdateResponse = batchUpdate(params, RequestOptions.none()) + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): AclBatchUpdateResponse = + batchUpdate( + params, RequestOptions.none() + ) /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): Acl = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ - fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Acl + fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl - /** A view of [AclService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [AclService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -98,29 +105,27 @@ interface AclService { */ @MustBeClosed fun create(params: AclCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: AclCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as - * [AclService.retrieve]. + * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the + * same as [AclService.retrieve]. */ @MustBeClosed fun retrieve(params: AclRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as @@ -128,55 +133,49 @@ interface AclService { */ @MustBeClosed fun list(params: AclListParams): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as - * [AclService.delete]. + * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the + * same as [AclService.delete]. */ @MustBeClosed fun delete(params: AclDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclService.batchUpdate]. + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise + * the same as [AclService.batchUpdate]. */ @MustBeClosed - fun batchUpdate(): HttpResponseFor = - batchUpdate(AclBatchUpdateParams.none()) + fun batchUpdate(): HttpResponseFor = batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): HttpResponseFor = batchUpdate(params, RequestOptions.none()) + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): HttpResponseFor = + batchUpdate( + params, RequestOptions.none() + ) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as @@ -184,13 +183,12 @@ interface AclService { */ @MustBeClosed fun findAndDelete(params: AclFindAndDeleteParams): HttpResponseFor = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index 39e18573..de7b127f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -25,11 +25,12 @@ import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -class AclServiceImpl internal constructor(private val clientOptions: ClientOptions) : AclService { +class AclServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: AclService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : AclService { + + private val withRawResponse: AclService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): AclService.WithRawResponse = withRawResponse @@ -49,186 +50,176 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).parse() - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): AclBatchUpdateResponse = + override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): AclBatchUpdateResponse = // post /v1/acl/batch-update withRawResponse().batchUpdate(params, requestOptions).parse() - override fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions, - ): Acl = + override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): Acl = // delete /v1/acl withRawResponse().findAndDelete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AclService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : AclService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: AclCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: AclCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: AclListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { AclListPage.of(AclServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: AclListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AclListPage.of(AclServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val batchUpdateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch-update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + batchUpdateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + findAndDeleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt index 867aab8c..b796ff67 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt @@ -18,211 +18,204 @@ import com.google.errorprone.annotations.MustBeClosed interface AiSecretService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will return the existing ai_secret unmodified + * Create a new ai_secret. If there is an existing ai_secret with the same name as + * the one specified in the request, will return the existing ai_secret unmodified */ - fun create(params: AiSecretCreateParams): AISecret = create(params, RequestOptions.none()) + fun create(params: AiSecretCreateParams): AISecret = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** Get an ai_secret object by its id */ - fun retrieve(params: AiSecretRetrieveParams): AISecret = retrieve(params, RequestOptions.none()) + fun retrieve(params: AiSecretRetrieveParams): AISecret = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** - * Partially update an ai_secret object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an ai_secret object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - fun update(params: AiSecretUpdateParams): AISecret = update(params, RequestOptions.none()) + fun update(params: AiSecretUpdateParams): AISecret = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ fun list(): AiSecretListPage = list(AiSecretListParams.none()) /** @see [list] */ - fun list( - params: AiSecretListParams = AiSecretListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AiSecretListPage + fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): AiSecretListPage /** @see [list] */ fun list(params: AiSecretListParams = AiSecretListParams.none()): AiSecretListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): AiSecretListPage = - list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): AiSecretListPage = list(AiSecretListParams.none(), requestOptions) /** Delete an ai_secret object by its id */ - fun delete(params: AiSecretDeleteParams): AISecret = delete(params, RequestOptions.none()) + fun delete(params: AiSecretDeleteParams): AISecret = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** Delete a single ai_secret */ fun findAndDelete(params: AiSecretFindAndDeleteParams): AISecret = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ - fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** - * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will replace the existing ai_secret with the provided fields + * Create or replace ai_secret. If there is an existing ai_secret with the same + * name as the one specified in the request, will replace the existing ai_secret + * with the provided fields */ - fun replace(params: AiSecretReplaceParams): AISecret = replace(params, RequestOptions.none()) + fun replace(params: AiSecretReplaceParams): AISecret = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret - /** A view of [AiSecretService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [AiSecretService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as - * [AiSecretService.create]. + * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same + * as [AiSecretService.create]. */ @MustBeClosed fun create(params: AiSecretCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the - * same as [AiSecretService.retrieve]. + * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretService.retrieve]. */ @MustBeClosed fun retrieve(params: AiSecretRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise - * the same as [AiSecretService.update]. + * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretService.update]. */ @MustBeClosed fun update(params: AiSecretUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as - * [AiSecretService.list]. + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same + * as [AiSecretService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(AiSecretListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: AiSecretListParams = AiSecretListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: AiSecretListParams = AiSecretListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: AiSecretListParams = AiSecretListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(AiSecretListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise - * the same as [AiSecretService.delete]. + * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretService.delete]. */ @MustBeClosed fun delete(params: AiSecretDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as - * [AiSecretService.findAndDelete]. + * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the + * same as [AiSecretService.findAndDelete]. */ @MustBeClosed fun findAndDelete(params: AiSecretFindAndDeleteParams): HttpResponseFor = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as - * [AiSecretService.replace]. + * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same + * as [AiSecretService.replace]. */ @MustBeClosed fun replace(params: AiSecretReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index 8824fdce..74bd1cac 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -25,12 +25,12 @@ import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams -class AiSecretServiceImpl internal constructor(private val clientOptions: ClientOptions) : - AiSecretService { +class AiSecretServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: AiSecretService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : AiSecretService { + + private val withRawResponse: AiSecretService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): AiSecretService.WithRawResponse = withRawResponse @@ -38,10 +38,7 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client // post /v1/ai_secret withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions, - ): AISecret = + override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): AISecret = // get /v1/ai_secret/{ai_secret_id} withRawResponse().retrieve(params, requestOptions).parse() @@ -49,10 +46,7 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client // patch /v1/ai_secret/{ai_secret_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: AiSecretListParams, - requestOptions: RequestOptions, - ): AiSecretListPage = + override fun list(params: AiSecretListParams, requestOptions: RequestOptions): AiSecretListPage = // get /v1/ai_secret withRawResponse().list(params, requestOptions).parse() @@ -60,10 +54,7 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client // delete /v1/ai_secret/{ai_secret_id} withRawResponse().delete(params, requestOptions).parse() - override fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions, - ): AISecret = + override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): AISecret = // delete /v1/ai_secret withRawResponse().findAndDelete(params, requestOptions).parse() @@ -71,198 +62,194 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client // put /v1/ai_secret withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AiSecretService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : AiSecretService.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: AiSecretListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { AiSecretListPage.of(AiSecretServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: AiSecretListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AiSecretListPage.of(AiSecretServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + findAndDeleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index 7f07d4a8..7f3aa7e6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -16,31 +16,31 @@ import com.google.errorprone.annotations.MustBeClosed interface ApiKeyService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is - * no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same + * name. There is no de-duplication */ fun create(params: ApiKeyCreateParams): CreateApiKeyOutput = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CreateApiKeyOutput + fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CreateApiKeyOutput /** Get an api_key object by its id */ - fun retrieve(params: ApiKeyRetrieveParams): ApiKey = retrieve(params, RequestOptions.none()) + fun retrieve(params: ApiKeyRetrieveParams): ApiKey = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ApiKey + fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey /** * List out all api_keys. The api_keys are sorted by creation date, with the most @@ -49,29 +49,30 @@ interface ApiKeyService { fun list(): ApiKeyListPage = list(ApiKeyListParams.none()) /** @see [list] */ - fun list( - params: ApiKeyListParams = ApiKeyListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ApiKeyListPage + fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ApiKeyListPage /** @see [list] */ fun list(params: ApiKeyListParams = ApiKeyListParams.none()): ApiKeyListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ApiKeyListPage = - list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ApiKeyListPage = list(ApiKeyListParams.none(), requestOptions) /** Delete an api_key object by its id */ - fun delete(params: ApiKeyDeleteParams): ApiKey = delete(params, RequestOptions.none()) + fun delete(params: ApiKeyDeleteParams): ApiKey = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ApiKey + fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey - /** A view of [ApiKeyService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ApiKeyService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -80,67 +81,62 @@ interface ApiKeyService { */ @MustBeClosed fun create(params: ApiKeyCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same - * as [ApiKeyService.retrieve]. + * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise + * the same as [ApiKeyService.retrieve]. */ @MustBeClosed fun retrieve(params: ApiKeyRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as * [ApiKeyService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(ApiKeyListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(ApiKeyListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ApiKeyListParams = ApiKeyListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ApiKeyListParams = ApiKeyListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ApiKeyListParams = ApiKeyListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ApiKeyListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the - * same as [ApiKeyService.delete]. + * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is + * otherwise the same as [ApiKeyService.delete]. */ @MustBeClosed fun delete(params: ApiKeyDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index cba100a5..92710f6f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -23,19 +23,16 @@ import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput -class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ApiKeyService { +class ApiKeyServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ApiKeyService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ApiKeyService { + + private val withRawResponse: ApiKeyService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ApiKeyService.WithRawResponse = withRawResponse - override fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions, - ): CreateApiKeyOutput = + override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CreateApiKeyOutput = // post /v1/api_key withRawResponse().create(params, requestOptions).parse() @@ -51,117 +48,116 @@ class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOp // delete /v1/api_key/{api_key_id} withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ApiKeyService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ApiKeyService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ApiKeyListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ApiKeyListPage.of(ApiKeyServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ApiKeyListPage.of(ApiKeyServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 91a18478..43c28c5e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -25,43 +25,45 @@ import com.google.errorprone.annotations.MustBeClosed interface DatasetService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified + * Create a new dataset. If there is an existing dataset in the project with the + * same name as the one specified in the request, will return the existing dataset + * unmodified */ - fun create(params: DatasetCreateParams): Dataset = create(params, RequestOptions.none()) + fun create(params: DatasetCreateParams): Dataset = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Dataset + fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** Get a dataset object by its id */ - fun retrieve(params: DatasetRetrieveParams): Dataset = retrieve(params, RequestOptions.none()) + fun retrieve(params: DatasetRetrieveParams): Dataset = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Dataset + fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** - * Partially update a dataset object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: DatasetUpdateParams): Dataset = update(params, RequestOptions.none()) + fun update(params: DatasetUpdateParams): Dataset = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Dataset + fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** * List out all datasets. The datasets are sorted by creation date, with the most @@ -70,87 +72,83 @@ interface DatasetService { fun list(): DatasetListPage = list(DatasetListParams.none()) /** @see [list] */ - fun list( - params: DatasetListParams = DatasetListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): DatasetListPage + fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): DatasetListPage /** @see [list] */ fun list(params: DatasetListParams = DatasetListParams.none()): DatasetListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): DatasetListPage = - list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): DatasetListPage = list(DatasetListParams.none(), requestOptions) /** Delete a dataset object by its id */ - fun delete(params: DatasetDeleteParams): Dataset = delete(params, RequestOptions.none()) + fun delete(params: DatasetDeleteParams): Dataset = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Dataset + fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** Log feedback for a set of dataset events */ fun feedback(params: DatasetFeedbackParams): FeedbackResponseSchema = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FeedbackResponseSchema + fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): FeedbackResponseSchema /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but + * with the parameters in the URL query rather than in the request body. For more + * complex queries, use the `POST /btql` endpoint. */ fun fetch(params: DatasetFetchParams): FetchDatasetEventsResponse = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchDatasetEventsResponse + fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): FetchDatasetEventsResponse /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but + * with the parameters in the request body rather than in the URL query. For more + * complex queries, use the `POST /btql` endpoint. */ fun fetchPost(params: DatasetFetchPostParams): FetchDatasetEventsResponse = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchDatasetEventsResponse + fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchDatasetEventsResponse /** Insert a set of events into the dataset */ fun insert(params: DatasetInsertParams): InsertEventsResponse = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): InsertEventsResponse + fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse /** Summarize dataset */ fun summarize(params: DatasetSummarizeParams): SummarizeDatasetResponse = - summarize(params, RequestOptions.none()) + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ - fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SummarizeDatasetResponse + fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeDatasetResponse - /** A view of [DatasetService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [DatasetService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -159,83 +157,77 @@ interface DatasetService { */ @MustBeClosed fun create(params: DatasetCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same - * as [DatasetService.retrieve]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise + * the same as [DatasetService.retrieve]. */ @MustBeClosed fun retrieve(params: DatasetRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the - * same as [DatasetService.update]. + * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is + * otherwise the same as [DatasetService.update]. */ @MustBeClosed fun update(params: DatasetUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as * [DatasetService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(DatasetListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(DatasetListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: DatasetListParams = DatasetListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: DatasetListParams = DatasetListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: DatasetListParams = DatasetListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(DatasetListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the - * same as [DatasetService.delete]. + * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is + * otherwise the same as [DatasetService.delete]. */ @MustBeClosed fun delete(params: DatasetDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is @@ -243,59 +235,55 @@ interface DatasetService { */ @MustBeClosed fun feedback(params: DatasetFeedbackParams): HttpResponseFor = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise - * the same as [DatasetService.fetch]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is + * otherwise the same as [DatasetService.fetch]. */ @MustBeClosed fun fetch(params: DatasetFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise - * the same as [DatasetService.fetchPost]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is + * otherwise the same as [DatasetService.fetchPost]. */ @MustBeClosed fun fetchPost(params: DatasetFetchPostParams): HttpResponseFor = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise - * the same as [DatasetService.insert]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is + * otherwise the same as [DatasetService.insert]. */ @MustBeClosed fun insert(params: DatasetInsertParams): HttpResponseFor = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is @@ -303,13 +291,12 @@ interface DatasetService { */ @MustBeClosed fun summarize(params: DatasetSummarizeParams): HttpResponseFor = - summarize(params, RequestOptions.none()) + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ @MustBeClosed - fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 033ed993..652d92dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -32,12 +32,12 @@ import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse -class DatasetServiceImpl internal constructor(private val clientOptions: ClientOptions) : - DatasetService { +class DatasetServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: DatasetService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : DatasetService { + + private val withRawResponse: DatasetService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): DatasetService.WithRawResponse = withRawResponse @@ -61,317 +61,290 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO // delete /v1/dataset/{dataset_id} withRawResponse().delete(params, requestOptions).parse() - override fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions, - ): FeedbackResponseSchema = + override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema = // post /v1/dataset/{dataset_id}/feedback withRawResponse().feedback(params, requestOptions).parse() - override fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions, - ): FetchDatasetEventsResponse = + override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): FetchDatasetEventsResponse = // get /v1/dataset/{dataset_id}/fetch withRawResponse().fetch(params, requestOptions).parse() - override fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions, - ): FetchDatasetEventsResponse = + override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): FetchDatasetEventsResponse = // post /v1/dataset/{dataset_id}/fetch withRawResponse().fetchPost(params, requestOptions).parse() - override fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions, - ): InsertEventsResponse = + override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): InsertEventsResponse = // post /v1/dataset/{dataset_id}/insert withRawResponse().insert(params, requestOptions).parse() - override fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions, - ): SummarizeDatasetResponse = + override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): SummarizeDatasetResponse = // get /v1/dataset/{dataset_id}/summarize withRawResponse().summarize(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DatasetService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : DatasetService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: DatasetListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { DatasetListPage.of(DatasetServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: DatasetListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DatasetListPage.of(DatasetServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + summarizeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt index 843a4762..4c8e6a9a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt @@ -17,43 +17,44 @@ import com.google.errorprone.annotations.MustBeClosed interface EnvVarService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new env_var. If there is an existing env_var with the same name as the one specified - * in the request, will return the existing env_var unmodified + * Create a new env_var. If there is an existing env_var with the same name as the + * one specified in the request, will return the existing env_var unmodified */ - fun create(params: EnvVarCreateParams): EnvVar = create(params, RequestOptions.none()) + fun create(params: EnvVarCreateParams): EnvVar = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar /** Get an env_var object by its id */ - fun retrieve(params: EnvVarRetrieveParams): EnvVar = retrieve(params, RequestOptions.none()) + fun retrieve(params: EnvVarRetrieveParams): EnvVar = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar /** - * Partially update an env_var object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an env_var object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: EnvVarUpdateParams): EnvVar = update(params, RequestOptions.none()) + fun update(params: EnvVarUpdateParams): EnvVar = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar /** * List out all env_vars. The env_vars are sorted by creation date, with the most @@ -62,41 +63,43 @@ interface EnvVarService { fun list(): EnvVarListResponse = list(EnvVarListParams.none()) /** @see [list] */ - fun list( - params: EnvVarListParams = EnvVarListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVarListResponse + fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): EnvVarListResponse /** @see [list] */ fun list(params: EnvVarListParams = EnvVarListParams.none()): EnvVarListResponse = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): EnvVarListResponse = - list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): EnvVarListResponse = list(EnvVarListParams.none(), requestOptions) /** Delete an env_var object by its id */ - fun delete(params: EnvVarDeleteParams): EnvVar = delete(params, RequestOptions.none()) + fun delete(params: EnvVarDeleteParams): EnvVar = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar /** - * Create or replace env_var. If there is an existing env_var with the same name as the one - * specified in the request, will replace the existing env_var with the provided fields + * Create or replace env_var. If there is an existing env_var with the same name as + * the one specified in the request, will replace the existing env_var with the + * provided fields */ - fun replace(params: EnvVarReplaceParams): EnvVar = replace(params, RequestOptions.none()) + fun replace(params: EnvVarReplaceParams): EnvVar = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar - /** A view of [EnvVarService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [EnvVarService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -105,44 +108,41 @@ interface EnvVarService { */ @MustBeClosed fun create(params: EnvVarCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same - * as [EnvVarService.retrieve]. + * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise + * the same as [EnvVarService.retrieve]. */ @MustBeClosed fun retrieve(params: EnvVarRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the - * same as [EnvVarService.update]. + * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is + * otherwise the same as [EnvVarService.update]. */ @MustBeClosed fun update(params: EnvVarUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as @@ -153,36 +153,32 @@ interface EnvVarService { /** @see [list] */ @MustBeClosed - fun list( - params: EnvVarListParams = EnvVarListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: EnvVarListParams = EnvVarListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: EnvVarListParams = EnvVarListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(EnvVarListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the - * same as [EnvVarService.delete]. + * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is + * otherwise the same as [EnvVarService.delete]. */ @MustBeClosed fun delete(params: EnvVarDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as @@ -190,13 +186,12 @@ interface EnvVarService { */ @MustBeClosed fun replace(params: EnvVarReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index aa611b8f..00059edc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams -class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOptions) : - EnvVarService { +class EnvVarServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: EnvVarService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : EnvVarService { + + private val withRawResponse: EnvVarService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): EnvVarService.WithRawResponse = withRawResponse @@ -45,10 +45,7 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp // patch /v1/env_var/{env_var_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: EnvVarListParams, - requestOptions: RequestOptions, - ): EnvVarListResponse = + override fun list(params: EnvVarListParams, requestOptions: RequestOptions): EnvVarListResponse = // get /v1/env_var withRawResponse().list(params, requestOptions).parse() @@ -60,169 +57,165 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp // put /v1/env_var withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - EnvVarService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : EnvVarService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list( - params: EnvVarListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: EnvVarListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt index fa1bcc99..2a8701e1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt @@ -11,27 +11,31 @@ import com.google.errorprone.annotations.MustBeClosed interface EvalService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into - * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and - * scoring functions. The API will then run the evaluation, create an experiment, and return the - * results along with a link to the experiment. To learn more about evals, see the + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is + * built into the Braintrust SDK. In the Eval API, you provide pointers to a + * dataset, task function, and scoring functions. The API will then run the + * evaluation, create an experiment, and return the results along with a link to + * the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ fun create(params: EvalCreateParams): SummarizeExperimentResponse = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SummarizeExperimentResponse + fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeExperimentResponse - /** A view of [EvalService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [EvalService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -40,13 +44,12 @@ interface EvalService { */ @MustBeClosed fun create(params: EvalCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index e761eba5..124d8a1c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -18,52 +18,50 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse -class EvalServiceImpl internal constructor(private val clientOptions: ClientOptions) : EvalService { +class EvalServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: EvalService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : EvalService { + + private val withRawResponse: EvalService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): EvalService.WithRawResponse = withRawResponse - override fun create( - params: EvalCreateParams, - requestOptions: RequestOptions, - ): SummarizeExperimentResponse = + override fun create(params: EvalCreateParams, requestOptions: RequestOptions): SummarizeExperimentResponse = // post /v1/eval withRawResponse().create(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - EvalService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : EvalService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun create( - params: EvalCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "eval") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun create(params: EvalCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "eval") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index 17bc351f..4a23c31f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -25,295 +25,278 @@ import com.google.errorprone.annotations.MustBeClosed interface ExperimentService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new experiment. If there is an existing experiment in the project with the same name - * as the one specified in the request, will return the existing experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with + * the same name as the one specified in the request, will return the existing + * experiment unmodified */ - fun create(params: ExperimentCreateParams): Experiment = create(params, RequestOptions.none()) + fun create(params: ExperimentCreateParams): Experiment = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Experiment + fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** Get an experiment object by its id */ fun retrieve(params: ExperimentRetrieveParams): Experiment = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Experiment + fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - fun update(params: ExperimentUpdateParams): Experiment = update(params, RequestOptions.none()) + fun update(params: ExperimentUpdateParams): Experiment = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Experiment + fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ fun list(): ExperimentListPage = list(ExperimentListParams.none()) /** @see [list] */ - fun list( - params: ExperimentListParams = ExperimentListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ExperimentListPage + fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ExperimentListPage /** @see [list] */ fun list(params: ExperimentListParams = ExperimentListParams.none()): ExperimentListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ExperimentListPage = - list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ExperimentListPage = list(ExperimentListParams.none(), requestOptions) /** Delete an experiment object by its id */ - fun delete(params: ExperimentDeleteParams): Experiment = delete(params, RequestOptions.none()) + fun delete(params: ExperimentDeleteParams): Experiment = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Experiment + fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** Log feedback for a set of experiment events */ fun feedback(params: ExperimentFeedbackParams): FeedbackResponseSchema = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FeedbackResponseSchema + fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): FeedbackResponseSchema /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the POST form of the same path, + * but with the parameters in the URL query rather than in the request body. For + * more complex queries, use the `POST /btql` endpoint. */ fun fetch(params: ExperimentFetchParams): FetchExperimentEventsResponse = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchExperimentEventsResponse + fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): FetchExperimentEventsResponse /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ fun fetchPost(params: ExperimentFetchPostParams): FetchExperimentEventsResponse = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchExperimentEventsResponse + fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchExperimentEventsResponse /** Insert a set of events into the experiment */ fun insert(params: ExperimentInsertParams): InsertEventsResponse = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): InsertEventsResponse + fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse /** Summarize experiment */ fun summarize(params: ExperimentSummarizeParams): SummarizeExperimentResponse = - summarize(params, RequestOptions.none()) + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ - fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SummarizeExperimentResponse + fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeExperimentResponse - /** A view of [ExperimentService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ExperimentService] that provides access to raw HTTP responses for + * each method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as - * [ExperimentService.create]. + * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same + * as [ExperimentService.create]. */ @MustBeClosed fun create(params: ExperimentCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentService.retrieve]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentService.retrieve]. */ @MustBeClosed fun retrieve(params: ExperimentRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentService.update]. + * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentService.update]. */ @MustBeClosed fun update(params: ExperimentUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as - * [ExperimentService.list]. + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same + * as [ExperimentService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(ExperimentListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ExperimentListParams = ExperimentListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ExperimentListParams = ExperimentListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ExperimentListParams = ExperimentListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ExperimentListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentService.delete]. + * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentService.delete]. */ @MustBeClosed fun delete(params: ExperimentDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is - * otherwise the same as [ExperimentService.feedback]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, + * but is otherwise the same as [ExperimentService.feedback]. */ @MustBeClosed fun feedback(params: ExperimentFeedbackParams): HttpResponseFor = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is - * otherwise the same as [ExperimentService.fetch]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but + * is otherwise the same as [ExperimentService.fetch]. */ @MustBeClosed fun fetch(params: ExperimentFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is - * otherwise the same as [ExperimentService.fetchPost]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but + * is otherwise the same as [ExperimentService.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: ExperimentFetchPostParams - ): HttpResponseFor = fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ExperimentFetchPostParams): HttpResponseFor = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is - * otherwise the same as [ExperimentService.insert]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, + * but is otherwise the same as [ExperimentService.insert]. */ @MustBeClosed fun insert(params: ExperimentInsertParams): HttpResponseFor = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is - * otherwise the same as [ExperimentService.summarize]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, + * but is otherwise the same as [ExperimentService.summarize]. */ @MustBeClosed - fun summarize( - params: ExperimentSummarizeParams - ): HttpResponseFor = summarize(params, RequestOptions.none()) + fun summarize(params: ExperimentSummarizeParams): HttpResponseFor = + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ @MustBeClosed - fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 7ec0526e..2fdf032d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -32,361 +32,319 @@ import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse -class ExperimentServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ExperimentService { +class ExperimentServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ExperimentService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ExperimentService { + + private val withRawResponse: ExperimentService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ExperimentService.WithRawResponse = withRawResponse - override fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions, - ): Experiment = + override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): Experiment = // post /v1/experiment withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions, - ): Experiment = + override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): Experiment = // get /v1/experiment/{experiment_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions, - ): Experiment = + override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): Experiment = // patch /v1/experiment/{experiment_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: ExperimentListParams, - requestOptions: RequestOptions, - ): ExperimentListPage = + override fun list(params: ExperimentListParams, requestOptions: RequestOptions): ExperimentListPage = // get /v1/experiment withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions, - ): Experiment = + override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): Experiment = // delete /v1/experiment/{experiment_id} withRawResponse().delete(params, requestOptions).parse() - override fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions, - ): FeedbackResponseSchema = + override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema = // post /v1/experiment/{experiment_id}/feedback withRawResponse().feedback(params, requestOptions).parse() - override fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions, - ): FetchExperimentEventsResponse = + override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): FetchExperimentEventsResponse = // get /v1/experiment/{experiment_id}/fetch withRawResponse().fetch(params, requestOptions).parse() - override fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions, - ): FetchExperimentEventsResponse = + override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): FetchExperimentEventsResponse = // post /v1/experiment/{experiment_id}/fetch withRawResponse().fetchPost(params, requestOptions).parse() - override fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions, - ): InsertEventsResponse = + override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): InsertEventsResponse = // post /v1/experiment/{experiment_id}/insert withRawResponse().insert(params, requestOptions).parse() - override fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions, - ): SummarizeExperimentResponse = + override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): SummarizeExperimentResponse = // get /v1/experiment/{experiment_id}/summarize withRawResponse().summarize(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ExperimentService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ExperimentService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ExperimentListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ExperimentListPage.of(ExperimentServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ExperimentListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ExperimentListPage.of(ExperimentServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + summarizeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index 2002b104..0a53085d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -20,43 +20,45 @@ import java.util.Optional interface FunctionService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified + * Create a new function. If there is an existing function in the project with the + * same slug as the one specified in the request, will return the existing function + * unmodified */ - fun create(params: FunctionCreateParams): Function = create(params, RequestOptions.none()) + fun create(params: FunctionCreateParams): Function = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** Get a function object by its id */ - fun retrieve(params: FunctionRetrieveParams): Function = retrieve(params, RequestOptions.none()) + fun retrieve(params: FunctionRetrieveParams): Function = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** - * Partially update a function object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: FunctionUpdateParams): Function = update(params, RequestOptions.none()) + fun update(params: FunctionUpdateParams): Function = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** * List out all functions. The functions are sorted by creation date, with the most @@ -65,98 +67,95 @@ interface FunctionService { fun list(): FunctionListPage = list(FunctionListParams.none()) /** @see [list] */ - fun list( - params: FunctionListParams = FunctionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): FunctionListPage + fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): FunctionListPage /** @see [list] */ fun list(params: FunctionListParams = FunctionListParams.none()): FunctionListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): FunctionListPage = - list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): FunctionListPage = list(FunctionListParams.none(), requestOptions) /** Delete a function object by its id */ - fun delete(params: FunctionDeleteParams): Function = delete(params, RequestOptions.none()) + fun delete(params: FunctionDeleteParams): Function = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** Invoke a function. */ fun invoke(params: FunctionInvokeParams): Optional = - invoke(params, RequestOptions.none()) + invoke( + params, RequestOptions.none() + ) /** @see [invoke] */ - fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Optional + fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): Optional /** - * Create or replace function. If there is an existing function in the project with the same - * slug as the one specified in the request, will replace the existing function with the - * provided fields + * Create or replace function. If there is an existing function in the project with + * the same slug as the one specified in the request, will replace the existing + * function with the provided fields */ - fun replace(params: FunctionReplaceParams): Function = replace(params, RequestOptions.none()) + fun replace(params: FunctionReplaceParams): Function = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Function - /** A view of [FunctionService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [FunctionService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as - * [FunctionService.create]. + * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same + * as [FunctionService.create]. */ @MustBeClosed fun create(params: FunctionCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the - * same as [FunctionService.retrieve]. + * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is + * otherwise the same as [FunctionService.retrieve]. */ @MustBeClosed fun retrieve(params: FunctionRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the - * same as [FunctionService.update]. + * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is + * otherwise the same as [FunctionService.update]. */ @MustBeClosed fun update(params: FunctionUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as @@ -167,52 +166,46 @@ interface FunctionService { /** @see [list] */ @MustBeClosed - fun list( - params: FunctionListParams = FunctionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: FunctionListParams = FunctionListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: FunctionListParams = FunctionListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(FunctionListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the - * same as [FunctionService.delete]. + * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is + * otherwise the same as [FunctionService.delete]. */ @MustBeClosed fun delete(params: FunctionDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is * otherwise the same as [FunctionService.invoke]. */ @MustBeClosed - fun invoke( - params: FunctionInvokeParams - ): HttpResponseFor> = invoke(params, RequestOptions.none()) + fun invoke(params: FunctionInvokeParams): HttpResponseFor> = + invoke( + params, RequestOptions.none() + ) /** @see [invoke] */ @MustBeClosed - fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor> /** * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as @@ -220,13 +213,12 @@ interface FunctionService { */ @MustBeClosed fun replace(params: FunctionReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index cf7eb4ad..0e8d7fb5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -27,12 +27,12 @@ import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams import java.util.Optional -class FunctionServiceImpl internal constructor(private val clientOptions: ClientOptions) : - FunctionService { +class FunctionServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: FunctionService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : FunctionService { + + private val withRawResponse: FunctionService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): FunctionService.WithRawResponse = withRawResponse @@ -40,10 +40,7 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client // post /v1/function withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions, - ): Function = + override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): Function = // get /v1/function/{function_id} withRawResponse().retrieve(params, requestOptions).parse() @@ -51,10 +48,7 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client // patch /v1/function/{function_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: FunctionListParams, - requestOptions: RequestOptions, - ): FunctionListPage = + override fun list(params: FunctionListParams, requestOptions: RequestOptions): FunctionListPage = // get /v1/function withRawResponse().list(params, requestOptions).parse() @@ -62,10 +56,7 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client // delete /v1/function/{function_id} withRawResponse().delete(params, requestOptions).parse() - override fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions, - ): Optional = + override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): Optional = // post /v1/function/{function_id}/invoke withRawResponse().invoke(params, requestOptions).parse() @@ -73,199 +64,194 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client // put /v1/function withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - FunctionService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : FunctionService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun list( - params: FunctionListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { FunctionListPage.of(FunctionServiceImpl(clientOptions), params, it) } - } + override fun list(params: FunctionListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + FunctionListPage.of(FunctionServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val invokeHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val invokeHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions, - ): HttpResponseFor> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { invokeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } - } - } - } + override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): HttpResponseFor> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function", params.getPathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + invokeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt index 5249cbc6..b5e07be5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt @@ -17,86 +17,89 @@ import com.google.errorprone.annotations.MustBeClosed interface GroupService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one + * specified in the request, will return the existing group unmodified */ - fun create(params: GroupCreateParams): Group = create(params, RequestOptions.none()) + fun create(params: GroupCreateParams): Group = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Group /** Get a group object by its id */ - fun retrieve(params: GroupRetrieveParams): Group = retrieve(params, RequestOptions.none()) + fun retrieve(params: GroupRetrieveParams): Group = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Group /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: GroupUpdateParams): Group = update(params, RequestOptions.none()) + fun update(params: GroupUpdateParams): Group = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Group /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ fun list(): GroupListPage = list(GroupListParams.none()) /** @see [list] */ - fun list( - params: GroupListParams = GroupListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): GroupListPage + fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): GroupListPage /** @see [list] */ fun list(params: GroupListParams = GroupListParams.none()): GroupListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): GroupListPage = - list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): GroupListPage = list(GroupListParams.none(), requestOptions) /** Delete a group object by its id */ - fun delete(params: GroupDeleteParams): Group = delete(params, RequestOptions.none()) + fun delete(params: GroupDeleteParams): Group = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Group /** - * Create or replace group. If there is an existing group with the same name as the one - * specified in the request, will replace the existing group with the provided fields + * Create or replace group. If there is an existing group with the same name as the + * one specified in the request, will replace the existing group with the provided + * fields */ - fun replace(params: GroupReplaceParams): Group = replace(params, RequestOptions.none()) + fun replace(params: GroupReplaceParams): Group = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Group - /** A view of [GroupService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [GroupService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -105,82 +108,77 @@ interface GroupService { */ @MustBeClosed fun create(params: GroupCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as - * [GroupService.retrieve]. + * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the + * same as [GroupService.retrieve]. */ @MustBeClosed fun retrieve(params: GroupRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same - * as [GroupService.update]. + * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise + * the same as [GroupService.update]. */ @MustBeClosed fun update(params: GroupUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as * [GroupService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(GroupListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(GroupListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: GroupListParams = GroupListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed fun list(params: GroupListParams = GroupListParams.none()): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(GroupListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same - * as [GroupService.delete]. + * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise + * the same as [GroupService.delete]. */ @MustBeClosed fun delete(params: GroupDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as @@ -188,13 +186,12 @@ interface GroupService { */ @MustBeClosed fun replace(params: GroupReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 84a146af..85b6d8c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -class GroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : - GroupService { +class GroupServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: GroupService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : GroupService { + + private val withRawResponse: GroupService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): GroupService.WithRawResponse = withRawResponse @@ -57,171 +57,168 @@ class GroupServiceImpl internal constructor(private val clientOptions: ClientOpt // put /v1/group withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - GroupService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : GroupService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: GroupCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: GroupCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: GroupListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { GroupListPage.of(GroupServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: GroupListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + GroupListPage.of(GroupServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt index b2ddae2c..969b1911 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt @@ -16,7 +16,8 @@ import com.google.errorprone.annotations.MustBeClosed interface OrganizationService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -24,60 +25,56 @@ interface OrganizationService { /** Get an organization object by its id */ fun retrieve(params: OrganizationRetrieveParams): Organization = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Organization + fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Organization /** - * Partially update an organization object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an organization object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: OrganizationUpdateParams): Organization = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Organization + fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Organization /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ fun list(): OrganizationListPage = list(OrganizationListParams.none()) /** @see [list] */ - fun list( - params: OrganizationListParams = OrganizationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): OrganizationListPage + fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): OrganizationListPage /** @see [list] */ fun list(params: OrganizationListParams = OrganizationListParams.none()): OrganizationListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): OrganizationListPage = - list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): OrganizationListPage = list(OrganizationListParams.none(), requestOptions) /** Delete an organization object by its id */ fun delete(params: OrganizationDeleteParams): Organization = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Organization + fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Organization /** - * A view of [OrganizationService] that provides access to raw HTTP responses for each method. + * A view of [OrganizationService] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -89,68 +86,62 @@ interface OrganizationService { */ @MustBeClosed fun retrieve(params: OrganizationRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is - * otherwise the same as [OrganizationService.update]. + * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but + * is otherwise the same as [OrganizationService.update]. */ @MustBeClosed fun update(params: OrganizationUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as - * [OrganizationService.list]. + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the + * same as [OrganizationService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(OrganizationListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: OrganizationListParams = OrganizationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: OrganizationListParams = OrganizationListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: OrganizationListParams = OrganizationListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(OrganizationListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is - * otherwise the same as [OrganizationService.delete]. + * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but + * is otherwise the same as [OrganizationService.delete]. */ @MustBeClosed fun delete(params: OrganizationDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index b6af330b..e3af7e0b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.OrganizationUpdateParams import com.braintrustdata.api.services.blocking.organizations.MemberService import com.braintrustdata.api.services.blocking.organizations.MemberServiceImpl -class OrganizationServiceImpl internal constructor(private val clientOptions: ClientOptions) : - OrganizationService { +class OrganizationServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: OrganizationService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : OrganizationService { + + private val withRawResponse: OrganizationService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } private val members: MemberService by lazy { MemberServiceImpl(clientOptions) } @@ -37,153 +37,136 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl override fun members(): MemberService = members - override fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions, - ): Organization = + override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): Organization = // get /v1/organization/{organization_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions, - ): Organization = + override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): Organization = // patch /v1/organization/{organization_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: OrganizationListParams, - requestOptions: RequestOptions, - ): OrganizationListPage = + override fun list(params: OrganizationListParams, requestOptions: RequestOptions): OrganizationListPage = // get /v1/organization withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions, - ): Organization = + override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): Organization = // delete /v1/organization/{organization_id} withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - OrganizationService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : OrganizationService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val members: MemberService.WithRawResponse by lazy { - MemberServiceImpl.WithRawResponseImpl(clientOptions) - } + private val members: MemberService.WithRawResponse by lazy { MemberServiceImpl.WithRawResponseImpl(clientOptions) } override fun members(): MemberService.WithRawResponse = members - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: OrganizationListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - OrganizationListPage.of(OrganizationServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: OrganizationListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + OrganizationListPage.of(OrganizationServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt index 5f9df9bc..338717ee 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt @@ -17,195 +17,182 @@ import com.google.errorprone.annotations.MustBeClosed interface ProjectScoreService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_score. If there is an existing project_score in the project with the - * same name as the one specified in the request, will return the existing project_score - * unmodified + * Create a new project_score. If there is an existing project_score in the project + * with the same name as the one specified in the request, will return the existing + * project_score unmodified */ fun create(params: ProjectScoreCreateParams): ProjectScore = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** Get a project_score object by its id */ fun retrieve(params: ProjectScoreRetrieveParams): ProjectScore = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: ProjectScoreUpdateParams): ProjectScore = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ fun list(): ProjectScoreListPage = list(ProjectScoreListParams.none()) /** @see [list] */ - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScoreListPage + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ProjectScoreListPage /** @see [list] */ fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): ProjectScoreListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ProjectScoreListPage = - list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ProjectScoreListPage = list(ProjectScoreListParams.none(), requestOptions) /** Delete a project_score object by its id */ fun delete(params: ProjectScoreDeleteParams): ProjectScore = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** - * Create or replace project_score. If there is an existing project_score in the project with - * the same name as the one specified in the request, will replace the existing project_score - * with the provided fields + * Create or replace project_score. If there is an existing project_score in the + * project with the same name as the one specified in the request, will replace the + * existing project_score with the provided fields */ fun replace(params: ProjectScoreReplaceParams): ProjectScore = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** - * A view of [ProjectScoreService] that provides access to raw HTTP responses for each method. + * A view of [ProjectScoreService] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as - * [ProjectScoreService.create]. + * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the + * same as [ProjectScoreService.create]. */ @MustBeClosed fun create(params: ProjectScoreCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreService.retrieve]. + * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but + * is otherwise the same as [ProjectScoreService.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectScoreRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreService.update]. + * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, + * but is otherwise the same as [ProjectScoreService.update]. */ @MustBeClosed fun update(params: ProjectScoreUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as - * [ProjectScoreService.list]. + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the + * same as [ProjectScoreService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(ProjectScoreListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectScoreListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreService.delete]. + * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, + * but is otherwise the same as [ProjectScoreService.delete]. */ @MustBeClosed fun delete(params: ProjectScoreDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as - * [ProjectScoreService.replace]. + * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the + * same as [ProjectScoreService.replace]. */ @MustBeClosed fun replace(params: ProjectScoreReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index ec7b0393..f6dad76f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -24,224 +24,201 @@ import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -class ProjectScoreServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectScoreService { +class ProjectScoreServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectScoreService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectScoreService { + + private val withRawResponse: ProjectScoreService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ProjectScoreService.WithRawResponse = withRawResponse - override fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): ProjectScore = // post /v1/project_score withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): ProjectScore = // get /v1/project_score/{project_score_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): ProjectScore = // patch /v1/project_score/{project_score_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions, - ): ProjectScoreListPage = + override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): ProjectScoreListPage = // get /v1/project_score withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): ProjectScore = // delete /v1/project_score/{project_score_id} withRawResponse().delete(params, requestOptions).parse() - override fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): ProjectScore = // put /v1/project_score withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectScoreService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ProjectScoreService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectScoreListPage.of(ProjectScoreServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectScoreListPage.of(ProjectScoreServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt index 197931d5..c48696e5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt @@ -17,45 +17,46 @@ import com.google.errorprone.annotations.MustBeClosed interface ProjectService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse fun logs(): LogService /** - * Create a new project. If there is an existing project with the same name as the one specified - * in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the + * one specified in the request, will return the existing project unmodified */ - fun create(params: ProjectCreateParams): Project = create(params, RequestOptions.none()) + fun create(params: ProjectCreateParams): Project = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Project + fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Project /** Get a project object by its id */ - fun retrieve(params: ProjectRetrieveParams): Project = retrieve(params, RequestOptions.none()) + fun retrieve(params: ProjectRetrieveParams): Project = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Project + fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Project /** - * Partially update a project object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: ProjectUpdateParams): Project = update(params, RequestOptions.none()) + fun update(params: ProjectUpdateParams): Project = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Project + fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Project /** * List out all projects. The projects are sorted by creation date, with the most @@ -64,29 +65,30 @@ interface ProjectService { fun list(): ProjectListPage = list(ProjectListParams.none()) /** @see [list] */ - fun list( - params: ProjectListParams = ProjectListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectListPage + fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ProjectListPage /** @see [list] */ fun list(params: ProjectListParams = ProjectListParams.none()): ProjectListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ProjectListPage = - list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ProjectListPage = list(ProjectListParams.none(), requestOptions) /** Delete a project object by its id */ - fun delete(params: ProjectDeleteParams): Project = delete(params, RequestOptions.none()) + fun delete(params: ProjectDeleteParams): Project = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Project + fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Project - /** A view of [ProjectService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ProjectService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { fun logs(): LogService.WithRawResponse @@ -97,82 +99,76 @@ interface ProjectService { */ @MustBeClosed fun create(params: ProjectCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same - * as [ProjectService.retrieve]. + * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise + * the same as [ProjectService.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the - * same as [ProjectService.update]. + * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is + * otherwise the same as [ProjectService.update]. */ @MustBeClosed fun update(params: ProjectUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as * [ProjectService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(ProjectListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(ProjectListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectListParams = ProjectListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ProjectListParams = ProjectListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ProjectListParams = ProjectListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the - * same as [ProjectService.delete]. + * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is + * otherwise the same as [ProjectService.delete]. */ @MustBeClosed fun delete(params: ProjectDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 502035c3..5f78530d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -25,12 +25,12 @@ import com.braintrustdata.api.models.ProjectUpdateParams import com.braintrustdata.api.services.blocking.projects.LogService import com.braintrustdata.api.services.blocking.projects.LogServiceImpl -class ProjectServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectService { +class ProjectServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectService { + + private val withRawResponse: ProjectService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } private val logs: LogService by lazy { LogServiceImpl(clientOptions) } @@ -58,150 +58,146 @@ class ProjectServiceImpl internal constructor(private val clientOptions: ClientO // delete /v1/project/{project_id} withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ProjectService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val logs: LogService.WithRawResponse by lazy { - LogServiceImpl.WithRawResponseImpl(clientOptions) - } + private val logs: LogService.WithRawResponse by lazy { LogServiceImpl.WithRawResponseImpl(clientOptions) } override fun logs(): LogService.WithRawResponse = logs - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ProjectListPage.of(ProjectServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectListPage.of(ProjectServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt index d06930e4..8c267908 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt @@ -17,120 +17,119 @@ import com.google.errorprone.annotations.MustBeClosed interface ProjectTagService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will return the existing project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project + * with the same name as the one specified in the request, will return the existing + * project_tag unmodified */ - fun create(params: ProjectTagCreateParams): ProjectTag = create(params, RequestOptions.none()) + fun create(params: ProjectTagCreateParams): ProjectTag = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag /** Get a project_tag object by its id */ fun retrieve(params: ProjectTagRetrieveParams): ProjectTag = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - fun update(params: ProjectTagUpdateParams): ProjectTag = update(params, RequestOptions.none()) + fun update(params: ProjectTagUpdateParams): ProjectTag = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ fun list(): ProjectTagListPage = list(ProjectTagListParams.none()) /** @see [list] */ - fun list( - params: ProjectTagListParams = ProjectTagListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTagListPage + fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ProjectTagListPage /** @see [list] */ fun list(params: ProjectTagListParams = ProjectTagListParams.none()): ProjectTagListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ProjectTagListPage = - list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ProjectTagListPage = list(ProjectTagListParams.none(), requestOptions) /** Delete a project_tag object by its id */ - fun delete(params: ProjectTagDeleteParams): ProjectTag = delete(params, RequestOptions.none()) + fun delete(params: ProjectTagDeleteParams): ProjectTag = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag /** - * Create or replace project_tag. If there is an existing project_tag in the project with the - * same name as the one specified in the request, will replace the existing project_tag with the - * provided fields + * Create or replace project_tag. If there is an existing project_tag in the + * project with the same name as the one specified in the request, will replace the + * existing project_tag with the provided fields */ fun replace(params: ProjectTagReplaceParams): ProjectTag = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag - /** A view of [ProjectTagService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ProjectTagService] that provides access to raw HTTP responses for + * each method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as - * [ProjectTagService.create]. + * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the + * same as [ProjectTagService.create]. */ @MustBeClosed fun create(params: ProjectTagCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise - * the same as [ProjectTagService.retrieve]. + * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagService.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectTagRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is @@ -138,68 +137,62 @@ interface ProjectTagService { */ @MustBeClosed fun update(params: ProjectTagUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as - * [ProjectTagService.list]. + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same + * as [ProjectTagService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(ProjectTagListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectTagListParams = ProjectTagListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ProjectTagListParams = ProjectTagListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ProjectTagListParams = ProjectTagListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectTagListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is - * otherwise the same as [ProjectTagService.delete]. + * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but + * is otherwise the same as [ProjectTagService.delete]. */ @MustBeClosed fun delete(params: ProjectTagDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as - * [ProjectTagService.replace]. + * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same + * as [ProjectTagService.replace]. */ @MustBeClosed fun replace(params: ProjectTagReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 79f8d590..94aaba01 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -24,222 +24,201 @@ import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -class ProjectTagServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectTagService { +class ProjectTagServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectTagService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectTagService { + + private val withRawResponse: ProjectTagService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ProjectTagService.WithRawResponse = withRawResponse - override fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): ProjectTag = // post /v1/project_tag withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): ProjectTag = // get /v1/project_tag/{project_tag_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): ProjectTag = // patch /v1/project_tag/{project_tag_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions, - ): ProjectTagListPage = + override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): ProjectTagListPage = // get /v1/project_tag withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): ProjectTag = // delete /v1/project_tag/{project_tag_id} withRawResponse().delete(params, requestOptions).parse() - override fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): ProjectTag = // put /v1/project_tag withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectTagService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ProjectTagService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ProjectTagListPage.of(ProjectTagServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectTagListPage.of(ProjectTagServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt index e3d04a03..c235c86f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt @@ -17,86 +17,90 @@ import com.google.errorprone.annotations.MustBeClosed interface PromptService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified + * Create a new prompt. If there is an existing prompt in the project with the same + * slug as the one specified in the request, will return the existing prompt + * unmodified */ - fun create(params: PromptCreateParams): Prompt = create(params, RequestOptions.none()) + fun create(params: PromptCreateParams): Prompt = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt /** Get a prompt object by its id */ - fun retrieve(params: PromptRetrieveParams): Prompt = retrieve(params, RequestOptions.none()) + fun retrieve(params: PromptRetrieveParams): Prompt = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt /** - * Partially update a prompt object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: PromptUpdateParams): Prompt = update(params, RequestOptions.none()) + fun update(params: PromptUpdateParams): Prompt = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ fun list(): PromptListPage = list(PromptListParams.none()) /** @see [list] */ - fun list( - params: PromptListParams = PromptListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): PromptListPage + fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): PromptListPage /** @see [list] */ fun list(params: PromptListParams = PromptListParams.none()): PromptListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): PromptListPage = - list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): PromptListPage = list(PromptListParams.none(), requestOptions) /** Delete a prompt object by its id */ - fun delete(params: PromptDeleteParams): Prompt = delete(params, RequestOptions.none()) + fun delete(params: PromptDeleteParams): Prompt = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as - * the one specified in the request, will replace the existing prompt with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the + * same slug as the one specified in the request, will replace the existing prompt + * with the provided fields */ - fun replace(params: PromptReplaceParams): Prompt = replace(params, RequestOptions.none()) + fun replace(params: PromptReplaceParams): Prompt = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt - /** A view of [PromptService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [PromptService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -105,83 +109,77 @@ interface PromptService { */ @MustBeClosed fun create(params: PromptCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same - * as [PromptService.retrieve]. + * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise + * the same as [PromptService.retrieve]. */ @MustBeClosed fun retrieve(params: PromptRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same - * as [PromptService.update]. + * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise + * the same as [PromptService.update]. */ @MustBeClosed fun update(params: PromptUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as * [PromptService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(PromptListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(PromptListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: PromptListParams = PromptListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: PromptListParams = PromptListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: PromptListParams = PromptListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(PromptListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the - * same as [PromptService.delete]. + * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is + * otherwise the same as [PromptService.delete]. */ @MustBeClosed fun delete(params: PromptDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as @@ -189,13 +187,12 @@ interface PromptService { */ @MustBeClosed fun replace(params: PromptReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index 7736249d..b8603315 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -class PromptServiceImpl internal constructor(private val clientOptions: ClientOptions) : - PromptService { +class PromptServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: PromptService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : PromptService { + + private val withRawResponse: PromptService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): PromptService.WithRawResponse = withRawResponse @@ -57,171 +57,168 @@ class PromptServiceImpl internal constructor(private val clientOptions: ClientOp // put /v1/prompt withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - PromptService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : PromptService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: PromptCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: PromptCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: PromptListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { PromptListPage.of(PromptServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: PromptListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + PromptListPage.of(PromptServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt index a913ecca..b1095a40 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt @@ -17,86 +17,89 @@ import com.google.errorprone.annotations.MustBeClosed interface RoleService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one + * specified in the request, will return the existing role unmodified */ - fun create(params: RoleCreateParams): Role = create(params, RequestOptions.none()) + fun create(params: RoleCreateParams): Role = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Role /** Get a role object by its id */ - fun retrieve(params: RoleRetrieveParams): Role = retrieve(params, RequestOptions.none()) + fun retrieve(params: RoleRetrieveParams): Role = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Role /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ - fun update(params: RoleUpdateParams): Role = update(params, RequestOptions.none()) + fun update(params: RoleUpdateParams): Role = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Role /** - * List out all roles. The roles are sorted by creation date, with the most recently-created - * roles coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ fun list(): RoleListPage = list(RoleListParams.none()) /** @see [list] */ - fun list( - params: RoleListParams = RoleListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): RoleListPage + fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): RoleListPage /** @see [list] */ fun list(params: RoleListParams = RoleListParams.none()): RoleListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): RoleListPage = - list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): RoleListPage = list(RoleListParams.none(), requestOptions) /** Delete a role object by its id */ - fun delete(params: RoleDeleteParams): Role = delete(params, RequestOptions.none()) + fun delete(params: RoleDeleteParams): Role = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Role /** - * Create or replace role. If there is an existing role with the same name as the one specified - * in the request, will replace the existing role with the provided fields + * Create or replace role. If there is an existing role with the same name as the + * one specified in the request, will replace the existing role with the provided + * fields */ - fun replace(params: RoleReplaceParams): Role = replace(params, RequestOptions.none()) + fun replace(params: RoleReplaceParams): Role = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Role - /** A view of [RoleService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [RoleService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -105,82 +108,77 @@ interface RoleService { */ @MustBeClosed fun create(params: RoleCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as - * [RoleService.retrieve]. + * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the + * same as [RoleService.retrieve]. */ @MustBeClosed fun retrieve(params: RoleRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as - * [RoleService.update]. + * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the + * same as [RoleService.update]. */ @MustBeClosed fun update(params: RoleUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as * [RoleService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(RoleListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(RoleListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: RoleListParams = RoleListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed fun list(params: RoleListParams = RoleListParams.none()): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(RoleListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as - * [RoleService.delete]. + * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise + * the same as [RoleService.delete]. */ @MustBeClosed fun delete(params: RoleDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as @@ -188,13 +186,12 @@ interface RoleService { */ @MustBeClosed fun replace(params: RoleReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index 8c0a69cb..7add91aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -24,11 +24,12 @@ import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -class RoleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RoleService { +class RoleServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: RoleService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : RoleService { + + private val withRawResponse: RoleService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): RoleService.WithRawResponse = withRawResponse @@ -56,171 +57,168 @@ class RoleServiceImpl internal constructor(private val clientOptions: ClientOpti // put /v1/role withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - RoleService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : RoleService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: RoleCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: RoleCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: RoleListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { RoleListPage.of(RoleServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: RoleListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + RoleListPage.of(RoleServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt index f8630cc6..cd1bc3c5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt @@ -17,119 +17,119 @@ import com.google.errorprone.annotations.MustBeClosed interface SpanIframeService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will return the existing span_iframe unmodified + * Create a new span_iframe. If there is an existing span_iframe with the same name + * as the one specified in the request, will return the existing span_iframe + * unmodified */ - fun create(params: SpanIframeCreateParams): SpanIFrame = create(params, RequestOptions.none()) + fun create(params: SpanIframeCreateParams): SpanIFrame = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame /** Get a span_iframe object by its id */ fun retrieve(params: SpanIframeRetrieveParams): SpanIFrame = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame /** - * Partially update a span_iframe object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a span_iframe object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - fun update(params: SpanIframeUpdateParams): SpanIFrame = update(params, RequestOptions.none()) + fun update(params: SpanIframeUpdateParams): SpanIFrame = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ fun list(): SpanIframeListPage = list(SpanIframeListParams.none()) /** @see [list] */ - fun list( - params: SpanIframeListParams = SpanIframeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIframeListPage + fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): SpanIframeListPage /** @see [list] */ fun list(params: SpanIframeListParams = SpanIframeListParams.none()): SpanIframeListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): SpanIframeListPage = - list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): SpanIframeListPage = list(SpanIframeListParams.none(), requestOptions) /** Delete a span_iframe object by its id */ - fun delete(params: SpanIframeDeleteParams): SpanIFrame = delete(params, RequestOptions.none()) + fun delete(params: SpanIframeDeleteParams): SpanIFrame = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame /** - * Create or replace span_iframe. If there is an existing span_iframe with the same name as the - * one specified in the request, will replace the existing span_iframe with the provided fields + * Create or replace span_iframe. If there is an existing span_iframe with the same + * name as the one specified in the request, will replace the existing span_iframe + * with the provided fields */ fun replace(params: SpanIframeReplaceParams): SpanIFrame = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame - /** A view of [SpanIframeService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [SpanIframeService] that provides access to raw HTTP responses for + * each method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as - * [SpanIframeService.create]. + * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the + * same as [SpanIframeService.create]. */ @MustBeClosed fun create(params: SpanIframeCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise - * the same as [SpanIframeService.retrieve]. + * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeService.retrieve]. */ @MustBeClosed fun retrieve(params: SpanIframeRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is @@ -137,68 +137,62 @@ interface SpanIframeService { */ @MustBeClosed fun update(params: SpanIframeUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as - * [SpanIframeService.list]. + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same + * as [SpanIframeService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(SpanIframeListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: SpanIframeListParams = SpanIframeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: SpanIframeListParams = SpanIframeListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: SpanIframeListParams = SpanIframeListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(SpanIframeListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is - * otherwise the same as [SpanIframeService.delete]. + * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but + * is otherwise the same as [SpanIframeService.delete]. */ @MustBeClosed fun delete(params: SpanIframeDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as - * [SpanIframeService.replace]. + * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same + * as [SpanIframeService.replace]. */ @MustBeClosed fun replace(params: SpanIframeReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt index 33029900..0e29471d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt @@ -24,222 +24,201 @@ import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams -class SpanIframeServiceImpl internal constructor(private val clientOptions: ClientOptions) : - SpanIframeService { +class SpanIframeServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: SpanIframeService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : SpanIframeService { + + private val withRawResponse: SpanIframeService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): SpanIframeService.WithRawResponse = withRawResponse - override fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): SpanIFrame = // post /v1/span_iframe withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): SpanIFrame = // get /v1/span_iframe/{span_iframe_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): SpanIFrame = // patch /v1/span_iframe/{span_iframe_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: SpanIframeListParams, - requestOptions: RequestOptions, - ): SpanIframeListPage = + override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): SpanIframeListPage = // get /v1/span_iframe withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): SpanIFrame = // delete /v1/span_iframe/{span_iframe_id} withRawResponse().delete(params, requestOptions).parse() - override fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): SpanIFrame = // put /v1/span_iframe withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - SpanIframeService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : SpanIframeService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: SpanIframeListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { SpanIframeListPage.of(SpanIframeServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SpanIframeListPage.of(SpanIframeServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt index f7d77d83..831f140a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt @@ -10,28 +10,33 @@ import com.google.errorprone.annotations.MustBeClosed interface TopLevelService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + /** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ fun helloWorld(): String = helloWorld(TopLevelHelloWorldParams.none()) /** @see [helloWorld] */ - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): String + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): String /** @see [helloWorld] */ fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): String = - helloWorld(params, RequestOptions.none()) + helloWorld( + params, RequestOptions.none() + ) /** @see [helloWorld] */ - fun helloWorld(requestOptions: RequestOptions): String = - helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): String = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) - /** A view of [TopLevelService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [TopLevelService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -43,20 +48,17 @@ interface TopLevelService { /** @see [helloWorld] */ @MustBeClosed - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [helloWorld] */ @MustBeClosed - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() - ): HttpResponseFor = helloWorld(params, RequestOptions.none()) + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): HttpResponseFor = + helloWorld( + params, RequestOptions.none() + ) /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(requestOptions: RequestOptions): HttpResponseFor = - helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): HttpResponseFor = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index 2bee0c27..0b9e70ab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -16,43 +16,44 @@ import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams -class TopLevelServiceImpl internal constructor(private val clientOptions: ClientOptions) : - TopLevelService { +class TopLevelServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: TopLevelService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : TopLevelService { + + private val withRawResponse: TopLevelService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): TopLevelService.WithRawResponse = withRawResponse - override fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions, - ): String = + override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): String = // get /v1 withRawResponse().helloWorld(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TopLevelService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : TopLevelService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = - stringHandler().withErrorHandler(errorHandler) - - override fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { helloWorldHandler.handle(it) } } + private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) + + override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + helloWorldHandler.handle(it) + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt index 8a297070..63bda6ec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt @@ -13,78 +13,78 @@ import com.google.errorprone.annotations.MustBeClosed interface UserService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Get a user object by its id */ - fun retrieve(params: UserRetrieveParams): User = retrieve(params, RequestOptions.none()) + fun retrieve(params: UserRetrieveParams): User = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): User + fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): User /** - * List out all users. The users are sorted by creation date, with the most recently-created - * users coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ fun list(): UserListPage = list(UserListParams.none()) /** @see [list] */ - fun list( - params: UserListParams = UserListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): UserListPage + fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): UserListPage /** @see [list] */ fun list(params: UserListParams = UserListParams.none()): UserListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): UserListPage = - list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): UserListPage = list(UserListParams.none(), requestOptions) - /** A view of [UserService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [UserService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as - * [UserService.retrieve]. + * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the + * same as [UserService.retrieve]. */ @MustBeClosed fun retrieve(params: UserRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as * [UserService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(UserListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(UserListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: UserListParams = UserListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed fun list(params: UserListParams = UserListParams.none()): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(UserListParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index 08e5047d..06605588 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -19,11 +19,12 @@ import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams -class UserServiceImpl internal constructor(private val clientOptions: ClientOptions) : UserService { +class UserServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: UserService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : UserService { + + private val withRawResponse: UserService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): UserService.WithRawResponse = withRawResponse @@ -35,63 +36,64 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti // get /v1/user withRawResponse().list(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - UserService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : UserService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun list( - params: UserListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { UserListPage.of(UserServiceImpl(clientOptions), params, it) } - } + override fun list(params: UserListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + UserListPage.of(UserServiceImpl(clientOptions), params, it) + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt index f997b1b2..100b76c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt @@ -17,78 +17,83 @@ import com.google.errorprone.annotations.MustBeClosed interface ViewService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one + * specified in the request, will return the existing view unmodified */ - fun create(params: ViewCreateParams): View = create(params, RequestOptions.none()) + fun create(params: ViewCreateParams): View = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): View /** Get a view object by its id */ - fun retrieve(params: ViewRetrieveParams): View = retrieve(params, RequestOptions.none()) + fun retrieve(params: ViewRetrieveParams): View = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): View /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ - fun update(params: ViewUpdateParams): View = update(params, RequestOptions.none()) + fun update(params: ViewUpdateParams): View = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): View /** - * List out all views. The views are sorted by creation date, with the most recently-created - * views coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ - fun list(params: ViewListParams): ViewListPage = list(params, RequestOptions.none()) + fun list(params: ViewListParams): ViewListPage = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list( - params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ViewListPage + fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): ViewListPage /** Delete a view object by its id */ - fun delete(params: ViewDeleteParams): View = delete(params, RequestOptions.none()) + fun delete(params: ViewDeleteParams): View = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): View /** - * Create or replace view. If there is an existing view with the same name as the one specified - * in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the + * one specified in the request, will replace the existing view with the provided + * fields */ - fun replace(params: ViewReplaceParams): View = replace(params, RequestOptions.none()) + fun replace(params: ViewReplaceParams): View = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): View - /** A view of [ViewService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ViewService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -97,44 +102,41 @@ interface ViewService { */ @MustBeClosed fun create(params: ViewCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as - * [ViewService.retrieve]. + * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the + * same as [ViewService.retrieve]. */ @MustBeClosed fun retrieve(params: ViewRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as - * [ViewService.update]. + * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the + * same as [ViewService.update]. */ @MustBeClosed fun update(params: ViewUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as @@ -142,29 +144,27 @@ interface ViewService { */ @MustBeClosed fun list(params: ViewListParams): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as - * [ViewService.delete]. + * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise + * the same as [ViewService.delete]. */ @MustBeClosed fun delete(params: ViewDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as @@ -172,13 +172,12 @@ interface ViewService { */ @MustBeClosed fun replace(params: ViewReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 8c11e74f..1ae3e726 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -24,11 +24,12 @@ import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -class ViewServiceImpl internal constructor(private val clientOptions: ClientOptions) : ViewService { +class ViewServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ViewService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ViewService { + + private val withRawResponse: ViewService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ViewService.WithRawResponse = withRawResponse @@ -56,171 +57,168 @@ class ViewServiceImpl internal constructor(private val clientOptions: ClientOpti // put /v1/view withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ViewService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ViewService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ViewCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ViewCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ViewListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ViewListPage.of(ViewServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ViewListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ViewListPage.of(ViewServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt index d6298636..1fc7b5c1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt @@ -11,7 +11,8 @@ import com.google.errorprone.annotations.MustBeClosed interface MemberService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -19,49 +20,43 @@ interface MemberService { fun update(): PatchOrganizationMembersOutput = update(OrganizationMemberUpdateParams.none()) /** @see [update] */ - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): PatchOrganizationMembersOutput + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): PatchOrganizationMembersOutput /** @see [update] */ - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() - ): PatchOrganizationMembersOutput = update(params, RequestOptions.none()) + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): PatchOrganizationMembersOutput = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update(requestOptions: RequestOptions): PatchOrganizationMembersOutput = - update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): PatchOrganizationMembersOutput = update(OrganizationMemberUpdateParams.none(), requestOptions) - /** A view of [MemberService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [MemberService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the - * same as [MemberService.update]. + * Returns a raw HTTP response for `patch /v1/organization/members`, but is + * otherwise the same as [MemberService.update]. */ @MustBeClosed - fun update(): HttpResponseFor = - update(OrganizationMemberUpdateParams.none()) + fun update(): HttpResponseFor = update(OrganizationMemberUpdateParams.none()) /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() - ): HttpResponseFor = update(params, RequestOptions.none()) + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): HttpResponseFor = + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - requestOptions: RequestOptions - ): HttpResponseFor = - update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): HttpResponseFor = update(OrganizationMemberUpdateParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index ffd783ac..c46ea290 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -18,53 +18,50 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput -class MemberServiceImpl internal constructor(private val clientOptions: ClientOptions) : - MemberService { +class MemberServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: MemberService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : MemberService { + + private val withRawResponse: MemberService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): MemberService.WithRawResponse = withRawResponse - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions, - ): PatchOrganizationMembersOutput = + override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): PatchOrganizationMembersOutput = // patch /v1/organization/members withRawResponse().update(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - MemberService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : MemberService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index 3289dca2..d5bd1944 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -16,121 +16,115 @@ import com.google.errorprone.annotations.MustBeClosed interface LogService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Log feedback for a set of project logs events */ fun feedback(params: ProjectLogFeedbackParams): FeedbackResponseSchema = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FeedbackResponseSchema + fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): FeedbackResponseSchema /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the POST form of the same + * path, but with the parameters in the URL query rather than in the request body. + * For more complex queries, use the `POST /btql` endpoint. */ fun fetch(params: ProjectLogFetchParams): FetchProjectLogsEventsResponse = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchProjectLogsEventsResponse + fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): FetchProjectLogsEventsResponse /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ fun fetchPost(params: ProjectLogFetchPostParams): FetchProjectLogsEventsResponse = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchProjectLogsEventsResponse + fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchProjectLogsEventsResponse /** Insert a set of events into the project logs */ fun insert(params: ProjectLogInsertParams): InsertEventsResponse = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): InsertEventsResponse + fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse - /** A view of [LogService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [LogService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is - * otherwise the same as [LogService.feedback]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, + * but is otherwise the same as [LogService.feedback]. */ @MustBeClosed fun feedback(params: ProjectLogFeedbackParams): HttpResponseFor = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is - * otherwise the same as [LogService.fetch]. + * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but + * is otherwise the same as [LogService.fetch]. */ @MustBeClosed fun fetch(params: ProjectLogFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is - * otherwise the same as [LogService.fetchPost]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but + * is otherwise the same as [LogService.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: ProjectLogFetchPostParams - ): HttpResponseFor = - fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ProjectLogFetchPostParams): HttpResponseFor = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is - * otherwise the same as [LogService.insert]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but + * is otherwise the same as [LogService.insert]. */ @MustBeClosed fun insert(params: ProjectLogInsertParams): HttpResponseFor = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index d060fec8..23884a8a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -23,156 +23,139 @@ import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -class LogServiceImpl internal constructor(private val clientOptions: ClientOptions) : LogService { +class LogServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: LogService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : LogService { + + private val withRawResponse: LogService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): LogService.WithRawResponse = withRawResponse - override fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions, - ): FeedbackResponseSchema = + override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema = // post /v1/project_logs/{project_id}/feedback withRawResponse().feedback(params, requestOptions).parse() - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions, - ): FetchProjectLogsEventsResponse = + override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse = // get /v1/project_logs/{project_id}/fetch withRawResponse().fetch(params, requestOptions).parse() - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions, - ): FetchProjectLogsEventsResponse = + override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse = // post /v1/project_logs/{project_id}/fetch withRawResponse().fetchPost(params, requestOptions).parse() - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions, - ): InsertEventsResponse = + override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): InsertEventsResponse = // post /v1/project_logs/{project_id}/insert withRawResponse().insert(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - LogService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : LogService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt index 1d2dd2d0..bfb17770 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt @@ -36,20 +36,16 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { $ prism mock path/to/your.openapi.yml """ .trimIndent(), - e, + e ) } } override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { - ConditionEvaluationResult.disabled( - "Environment variable $SKIP_TESTS_ENV is set to true" - ) + ConditionEvaluationResult.disabled("Environment variable $SKIP_TESTS_ENV is set to true") } else { - ConditionEvaluationResult.enabled( - "Environment variable $SKIP_TESTS_ENV is not set to true" - ) + ConditionEvaluationResult.enabled("Environment variable $SKIP_TESTS_ENV is not set to true") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt index a7a9b514..afe2bc55 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt @@ -1,7 +1,7 @@ package com.braintrustdata.api.core -import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat internal class PhantomReachableTest { @@ -11,10 +11,8 @@ internal class PhantomReachableTest { val closeable = AutoCloseable { closed = true } closeWhenPhantomReachable( - // Pass an inline object for the object to observe so that it becomes immediately - // unreachable. - Any(), - closeable, + // Pass an inline object for the object to observe so that it becomes immediately unreachable. + Any(), closeable ) assertThat(closed).isFalse() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt index fcdb9f5c..5fed9eeb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt @@ -27,55 +27,55 @@ internal class ValuesTest { KNOWN_BOOLEAN( KnownValue.of(true), expectedAsKnown = Optional.of(true), - expectedAsBoolean = Optional.of(true), + expectedAsBoolean = Optional.of(true) ), BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), KNOWN_NUMBER( KnownValue.of(42), expectedAsKnown = Optional.of(42), - expectedAsNumber = Optional.of(42), + expectedAsNumber = Optional.of(42) ), NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), KNOWN_STRING( KnownValue.of("hello"), expectedAsKnown = Optional.of("hello"), - expectedAsString = Optional.of("hello"), + expectedAsString = Optional.of("hello") ), STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), KNOWN_ARRAY_NOT_ALL_JSON( KnownValue.of(listOf("a", "b", NON_JSON)), - expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)) ), KNOWN_ARRAY( KnownValue.of(listOf("a", "b", "c")), expectedAsKnown = Optional.of(listOf("a", "b", "c")), expectedAsArray = - Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))) ), ARRAY( JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), expectedAsArray = - Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))) ), KNOWN_OBJECT_NOT_ALL_STRING_KEYS( KnownValue.of(mapOf("a" to "b", 42 to "c")), - expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")) ), KNOWN_OBJECT_NOT_ALL_JSON( KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), - expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)) ), KNOWN_OBJECT( KnownValue.of(mapOf("a" to "b", "b" to "c")), expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), expectedAsObject = - Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))) ), OBJECT( JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), expectedAsObject = - Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), - ), + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))) + ) } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt index 2a5ed57a..f66d69ea 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt @@ -1,8 +1,9 @@ package com.braintrustdata.api.core.http +import org.junit.jupiter.api.Test import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat +import org.assertj.core.api.Assumptions.assumeThat; import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -11,28 +12,28 @@ internal class HeadersTest { enum class TestCase( val headers: Headers, val expectedMap: Map>, - val expectedSize: Int, + val expectedSize: Int ) { EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( Headers.builder().put("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), PUT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT( Headers.builder().put("name1", "value").put("name2", "value").build(), expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT_SAME_NAME( Headers.builder().put("name", "value1").put("name", "value2").build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT_MULTIPLE( Headers.builder() @@ -40,7 +41,7 @@ internal class HeadersTest { .put("name", listOf("value1", "value2")) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4, + expectedSize = 4 ), PUT_CASE_INSENSITIVE( Headers.builder() @@ -49,25 +50,25 @@ internal class HeadersTest { .put("nAmE", "value3") .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3, + expectedSize = 3 ), PUT_ALL_MAP( Headers.builder() .putAll( mapOf( "name1" to listOf("value1", "value2"), - "name2" to listOf("value1", "value2"), + "name2" to listOf("value1", "value2") ) ) .build(), expectedMap = mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), - expectedSize = 4, + expectedSize = 4 ), PUT_ALL_HEADERS( Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), PUT_ALL_CASE_INSENSITIVE( Headers.builder() @@ -75,32 +76,32 @@ internal class HeadersTest { mapOf( "name" to listOf("value1"), "NAME" to listOf("value2"), - "nAmE" to listOf("value3"), + "nAmE" to listOf("value3") ) ) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3, + expectedSize = 3 ), REMOVE_ABSENT( Headers.builder().remove("name").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_PRESENT_ONE( Headers.builder().put("name", "value").remove("name").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_PRESENT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_CASE_INSENSITIVE( Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_ALL( Headers.builder() @@ -109,7 +110,7 @@ internal class HeadersTest { .removeAll(setOf("name1", "name2", "name3")) .build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -118,22 +119,22 @@ internal class HeadersTest { .removeAll(setOf("NAME1", "nAmE3")) .build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), CLEAR( Headers.builder().put("name1", "value").put("name2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REPLACE_ONE_ABSENT( Headers.builder().replace("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_ONE_PRESENT_ONE( Headers.builder().put("name", "value1").replace("name", "value2").build(), expectedMap = mapOf("name" to listOf("value2")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_ONE_PRESENT_MULTIPLE( Headers.builder() @@ -141,12 +142,12 @@ internal class HeadersTest { .replace("name", "value3") .build(), expectedMap = mapOf("name" to listOf("value3")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_MULTIPLE_ABSENT( Headers.builder().replace("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_MULTIPLE_PRESENT_ONE( Headers.builder() @@ -154,7 +155,7 @@ internal class HeadersTest { .replace("name", listOf("value2", "value3")) .build(), expectedMap = mapOf("name" to listOf("value2", "value3")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( Headers.builder() @@ -162,7 +163,7 @@ internal class HeadersTest { .replace("name", listOf("value3", "value4")) .build(), expectedMap = mapOf("name" to listOf("value3", "value4")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_CASE_INSENSITIVE( Headers.builder() @@ -170,7 +171,7 @@ internal class HeadersTest { .replace("NAME", listOf("value2", "value3")) .build(), expectedMap = mapOf("NAME" to listOf("value2", "value3")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_ALL_MAP( Headers.builder() @@ -183,9 +184,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2"), + "name3" to listOf("value2") ), - expectedSize = 3, + expectedSize = 3 ), REPLACE_ALL_HEADERS( Headers.builder() @@ -198,9 +199,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2"), + "name3" to listOf("value2") ), - expectedSize = 3, + expectedSize = 3 ), REPLACE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -209,8 +210,8 @@ internal class HeadersTest { .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) .build(), expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), - expectedSize = 2, - ), + expectedSize = 2 + ) } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt index 08e55c66..7fe37959 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt @@ -1,8 +1,9 @@ package com.braintrustdata.api.core.http +import org.junit.jupiter.api.Test import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat +import org.assertj.core.api.Assumptions.assumeThat; import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -11,28 +12,28 @@ internal class QueryParamsTest { enum class TestCase( val queryParams: QueryParams, val expectedMap: Map>, - val expectedSize: Int, + val expectedSize: Int ) { EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( QueryParams.builder().put("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), PUT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT( QueryParams.builder().put("key1", "value").put("key2", "value").build(), expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT_SAME_NAME( QueryParams.builder().put("key", "value1").put("key", "value2").build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT_MULTIPLE( QueryParams.builder() @@ -40,40 +41,40 @@ internal class QueryParamsTest { .put("key", listOf("value1", "value2")) .build(), expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4, + expectedSize = 4 ), PUT_ALL_MAP( QueryParams.builder() .putAll( mapOf( "key1" to listOf("value1", "value2"), - "key2" to listOf("value1", "value2"), + "key2" to listOf("value1", "value2") ) ) .build(), expectedMap = mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), - expectedSize = 4, + expectedSize = 4 ), PUT_ALL_HEADERS( QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), REMOVE_ABSENT( QueryParams.builder().remove("key").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_PRESENT_ONE( QueryParams.builder().put("key", "value").remove("key").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_PRESENT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_ALL( QueryParams.builder() @@ -82,22 +83,22 @@ internal class QueryParamsTest { .removeAll(setOf("key1", "key2", "key3")) .build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), CLEAR( QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REPLACE_ONE_ABSENT( QueryParams.builder().replace("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_ONE_PRESENT_ONE( QueryParams.builder().put("key", "value1").replace("key", "value2").build(), expectedMap = mapOf("key" to listOf("value2")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_ONE_PRESENT_MULTIPLE( QueryParams.builder() @@ -105,12 +106,12 @@ internal class QueryParamsTest { .replace("key", "value3") .build(), expectedMap = mapOf("key" to listOf("value3")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_MULTIPLE_ABSENT( QueryParams.builder().replace("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_MULTIPLE_PRESENT_ONE( QueryParams.builder() @@ -118,7 +119,7 @@ internal class QueryParamsTest { .replace("key", listOf("value2", "value3")) .build(), expectedMap = mapOf("key" to listOf("value2", "value3")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( QueryParams.builder() @@ -126,7 +127,7 @@ internal class QueryParamsTest { .replace("key", listOf("value3", "value4")) .build(), expectedMap = mapOf("key" to listOf("value3", "value4")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_ALL_MAP( QueryParams.builder() @@ -139,9 +140,9 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2"), + "key3" to listOf("value2") ), - expectedSize = 3, + expectedSize = 3 ), REPLACE_ALL_HEADERS( QueryParams.builder() @@ -156,10 +157,10 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2"), + "key3" to listOf("value2") ), - expectedSize = 3, - ), + expectedSize = 3 + ) } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt index d538b9b3..9370b6d7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt @@ -6,12 +6,12 @@ import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario -import java.io.InputStream -import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource +import java.io.InputStream +import java.util.concurrent.CompletableFuture @WireMockTest internal class RetryingHttpClientTest { @@ -26,12 +26,12 @@ internal class RetryingHttpClientTest { object : HttpClient { override fun execute( request: HttpRequest, - requestOptions: RequestOptions, + requestOptions: RequestOptions ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions, + requestOptions: RequestOptions ): CompletableFuture = okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } @@ -71,7 +71,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) @@ -97,7 +97,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) @@ -140,24 +140,24 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("0")), + .withHeader("x-stainless-retry-count", equalTo("0")) ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("1")), + .withHeader("x-stainless-retry-count", equalTo("1")) ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("2")), + .withHeader("x-stainless-retry-count", equalTo("2")) ) assertNoResponseLeaks() } @@ -191,14 +191,14 @@ internal class RetryingHttpClientTest { .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) verify( 2, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("42")), + .withHeader("x-stainless-retry-count", equalTo("42")) ) assertNoResponseLeaks() } @@ -226,7 +226,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt index 824c8711..3759f563 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt @@ -1,13 +1,13 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.core.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.* +import com.braintrustdata.api.core.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import java.util.* internal class SerializerTest { @JsonDeserialize(builder = ClassWithBooleanFieldPrefixedWithIs.Builder::class) @@ -23,7 +23,9 @@ internal class SerializerTest { fun isActive(): Boolean? = isActive.getNullable("is_active") - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + @JsonProperty("is_active") + @ExcludeMissing + fun _isActive() = isActive @JsonAnyGetter @ExcludeMissing @@ -42,19 +44,21 @@ internal class SerializerTest { } return other is ClassWithBooleanFieldPrefixedWithIs && - isActive == other.isActive && - additionalProperties == other.additionalProperties + isActive == other.isActive && + additionalProperties == other.additionalProperties } override fun hashCode(): Int { if (hashCode == 0) { - hashCode = Objects.hash(isActive, additionalProperties) + hashCode = Objects.hash( + isActive, + additionalProperties, + ) } return hashCode } - override fun toString() = - "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" + override fun toString() = "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" companion object { fun builder() = Builder() @@ -70,7 +74,9 @@ internal class SerializerTest { @JsonProperty("is_active") @ExcludeMissing - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } + fun isActive(isActive: JsonField) = apply { + this.isActive = isActive + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -86,11 +92,14 @@ internal class SerializerTest { this.additionalProperties.putAll(additionalProperties) } - fun build(): ClassWithBooleanFieldPrefixedWithIs = - ClassWithBooleanFieldPrefixedWithIs(isActive, additionalProperties.toImmutable()) + fun build(): ClassWithBooleanFieldPrefixedWithIs = ClassWithBooleanFieldPrefixedWithIs( + isActive, + additionalProperties.toImmutable(), + ) } } + @Test fun serializeBooleanPrefixedWithIs() { val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt index 693b9866..5d5e9323 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt @@ -11,32 +11,26 @@ class AISecretTest { @Test fun createAISecret() { - val aiSecret = - AISecret.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata( - AISecret.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .previewSecret("preview_secret") - .type("type") - .build() - assertThat(aiSecret).isNotNull - assertThat(aiSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(aiSecret.name()).isEqualTo("name") - assertThat(aiSecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(aiSecret.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(aiSecret.metadata()) - .contains( - AISecret.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(aiSecret.previewSecret()).contains("preview_secret") - assertThat(aiSecret.type()).contains("type") + val aiSecret = AISecret.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(AISecret.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .previewSecret("preview_secret") + .type("type") + .build() + assertThat(aiSecret).isNotNull + assertThat(aiSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aiSecret.name()).isEqualTo("name") + assertThat(aiSecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aiSecret.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(aiSecret.metadata()).contains(AISecret.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(aiSecret.previewSecret()).contains("preview_secret") + assertThat(aiSecret.type()).contains("type") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt index ce3f43d3..942ae28c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt @@ -10,109 +10,80 @@ class AclBatchUpdateParamsTest { @Test fun create() { - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() + AclBatchUpdateParams.builder() + .addAddAcl(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() } @Test fun body() { - val params = - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() + val params = AclBatchUpdateParams.builder() + .addAddAcl(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.addAcls()) - .contains( - listOf( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) - assertThat(body.removeAcls()) - .contains( - listOf( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) + assertNotNull(body) + assertThat(body.addAcls()).contains(listOf(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build())) + assertThat(body.removeAcls()).contains(listOf(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = AclBatchUpdateParams.builder().build() + val params = AclBatchUpdateParams.builder().build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponseTest.kt index 02a37951..b862daca 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponseTest.kt @@ -10,67 +10,56 @@ class AclBatchUpdateResponseTest { @Test fun createAclBatchUpdateResponse() { - val aclBatchUpdateResponse = - AclBatchUpdateResponse.builder() - .addAddedAcl( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemovedAcl( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - assertThat(aclBatchUpdateResponse).isNotNull - assertThat(aclBatchUpdateResponse.addedAcls()) - .containsExactly( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - assertThat(aclBatchUpdateResponse.removedAcls()) - .containsExactly( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val aclBatchUpdateResponse = AclBatchUpdateResponse.builder() + .addAddedAcl(Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemovedAcl(Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() + assertThat(aclBatchUpdateResponse).isNotNull + assertThat(aclBatchUpdateResponse.addedAcls()).containsExactly(Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + assertThat(aclBatchUpdateResponse.removedAcls()).containsExactly(Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt index 2f1cbe6c..33bf5671 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt @@ -10,55 +10,52 @@ class AclCreateParamsTest { @Test fun create() { - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) - assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).contains(AclCreateParams.Permission.CREATE) - assertThat(body.restrictObjectType()) - .contains(AclCreateParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) + assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).contains(AclCreateParams.Permission.CREATE) + assertThat(body.restrictObjectType()).contains(AclCreateParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun bodyWithoutOptionalFields() { - val params = - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .build() + val params = AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt index 51793459..cd7e95c7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt @@ -9,16 +9,20 @@ class AclDeleteParamsTest { @Test fun create() { - AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + AclDeleteParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "aclId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AclDeleteParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aclId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParamsTest.kt index 8c64fe8b..335f462e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclFindAndDeleteParamsTest.kt @@ -10,55 +10,52 @@ class AclFindAndDeleteParamsTest { @Test fun create() { - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).contains(AclFindAndDeleteParams.Permission.CREATE) - assertThat(body.restrictObjectType()) - .contains(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).contains(AclFindAndDeleteParams.Permission.CREATE) + assertThat(body.restrictObjectType()).contains(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun bodyWithoutOptionalFields() { - val params = - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .build() + val params = AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt index 174747e9..09d041f2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt @@ -10,50 +10,45 @@ class AclListParamsTest { @Test fun create() { - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt index fd23f612..d3e50fea 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class AclRetrieveParamsTest { @Test fun create() { - AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + AclRetrieveParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "aclId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AclRetrieveParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aclId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt index cedb7fe5..2bd881dc 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt @@ -10,29 +10,28 @@ class AclTest { @Test fun createAcl() { - val acl = - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(acl).isNotNull - assertThat(acl.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl._objectOrgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.objectType()).isEqualTo(Acl.ObjectType.ORGANIZATION) - assertThat(acl.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(acl.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.permission()).contains(Acl.Permission.CREATE) - assertThat(acl.restrictObjectType()).contains(Acl.RestrictObjectType.ORGANIZATION) - assertThat(acl.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val acl = Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(acl).isNotNull + assertThat(acl.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(acl._objectOrgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(acl.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(acl.objectType()).isEqualTo(Acl.ObjectType.ORGANIZATION) + assertThat(acl.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(acl.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(acl.permission()).contains(Acl.Permission.CREATE) + assertThat(acl.restrictObjectType()).contains(Acl.RestrictObjectType.ORGANIZATION) + assertThat(acl.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(acl.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt index 213130fd..d00281be 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt @@ -11,56 +11,50 @@ class AiSecretCreateParamsTest { @Test fun create() { - AiSecretCreateParams.builder() - .name("name") - .metadata( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() + AiSecretCreateParams.builder() + .name("name") + .metadata(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() } @Test fun body() { - val params = - AiSecretCreateParams.builder() - .name("name") - .metadata( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()) - .contains( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.orgName()).contains("org_name") - assertThat(body.secret()).contains("secret") - assertThat(body.type()).contains("type") + val params = AiSecretCreateParams.builder() + .name("name") + .metadata(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.metadata()).contains(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.orgName()).contains("org_name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretCreateParams.builder().name("name").build() + val params = AiSecretCreateParams.builder() + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt index a59725a1..98eaa5fd 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt @@ -9,19 +9,20 @@ class AiSecretDeleteParamsTest { @Test fun create() { - AiSecretDeleteParams.builder().aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aiSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aiSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt index f46d2fb2..dd00f4fc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt @@ -10,27 +10,35 @@ class AiSecretFindAndDeleteParamsTest { @Test fun create() { - AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() + AiSecretFindAndDeleteParams.builder() + .name("name") + .orgName("org_name") + .build() } @Test fun body() { - val params = AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() + val params = AiSecretFindAndDeleteParams.builder() + .name("name") + .orgName("org_name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).contains("org_name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretFindAndDeleteParams.builder().name("name").build() + val params = AiSecretFindAndDeleteParams.builder() + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt index fff7ec47..9388f3ff 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt @@ -10,50 +10,43 @@ class AiSecretListParamsTest { @Test fun create() { - AiSecretListParams.builder() - .aiSecretName("ai_secret_name") - .aiSecretType("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AiSecretListParams.builder() + .aiSecretName("ai_secret_name") + .aiSecretType("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - AiSecretListParams.builder() - .aiSecretName("ai_secret_name") - .aiSecretType("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ai_secret_name", "ai_secret_name") - expected.put( - "ai_secret_type", - AiSecretListParams.AiSecretType.ofString("string").toString(), - ) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = AiSecretListParams.builder() + .aiSecretName("ai_secret_name") + .aiSecretType("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ai_secret_name", "ai_secret_name") + expected.put("ai_secret_type", AiSecretListParams.AiSecretType.ofString("string").toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = AiSecretListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = AiSecretListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt index b716129c..96bc3a6a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt @@ -11,56 +11,50 @@ class AiSecretReplaceParamsTest { @Test fun create() { - AiSecretReplaceParams.builder() - .name("name") - .metadata( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() + AiSecretReplaceParams.builder() + .name("name") + .metadata(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() } @Test fun body() { - val params = - AiSecretReplaceParams.builder() - .name("name") - .metadata( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()) - .contains( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.orgName()).contains("org_name") - assertThat(body.secret()).contains("secret") - assertThat(body.type()).contains("type") + val params = AiSecretReplaceParams.builder() + .name("name") + .metadata(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.metadata()).contains(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.orgName()).contains("org_name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretReplaceParams.builder().name("name").build() + val params = AiSecretReplaceParams.builder() + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt index 5c6d07cc..0eddf89f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt @@ -9,19 +9,20 @@ class AiSecretRetrieveParamsTest { @Test fun create() { - AiSecretRetrieveParams.builder().aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aiSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aiSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt index b45e1c86..17084aa8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt @@ -11,70 +11,60 @@ class AiSecretUpdateParamsTest { @Test fun create() { - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .secret("secret") - .type("type") - .build() + AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .secret("secret") + .type("type") + .build() } @Test fun body() { - val params = - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .secret("secret") - .type("type") - .build() + val params = AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .secret("secret") + .type("type") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.metadata()) - .contains( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.name()).contains("name") - assertThat(body.secret()).contains("secret") - assertThat(body.type()).contains("type") + assertNotNull(body) + assertThat(body.metadata()).contains(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.name()).contains("name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test fun bodyWithoutOptionalFields() { - val params = - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aiSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aiSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt index d450a958..683112d5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt @@ -10,27 +10,35 @@ class ApiKeyCreateParamsTest { @Test fun create() { - ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + ApiKeyCreateParams.builder() + .name("name") + .orgName("org_name") + .build() } @Test fun body() { - val params = ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + val params = ApiKeyCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).contains("org_name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = ApiKeyCreateParams.builder().name("name").build() + val params = ApiKeyCreateParams.builder() + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt index 0b7c5a7d..6de59487 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt @@ -9,17 +9,20 @@ class ApiKeyDeleteParamsTest { @Test fun create() { - ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "apiKeyId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "apiKeyId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index 41532fd3..9f6485af 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -10,44 +10,40 @@ class ApiKeyListParamsTest { @Test fun create() { - ApiKeyListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ApiKeyListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ApiKeyListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("api_key_name", "api_key_name") - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ApiKeyListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("api_key_name", "api_key_name") + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ApiKeyListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ApiKeyListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt index 2170ff30..29fe0c51 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class ApiKeyRetrieveParamsTest { @Test fun create() { - ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "apiKeyId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "apiKeyId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt index 5d9ab3b9..4893810a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt @@ -10,21 +10,20 @@ class ApiKeyTest { @Test fun createApiKey() { - val apiKey = - ApiKey.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .previewName("preview_name") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(apiKey).isNotNull - assertThat(apiKey.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(apiKey.name()).isEqualTo("name") - assertThat(apiKey.previewName()).isEqualTo("preview_name") - assertThat(apiKey.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(apiKey.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(apiKey.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val apiKey = ApiKey.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .previewName("preview_name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(apiKey).isNotNull + assertThat(apiKey.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKey.name()).isEqualTo("name") + assertThat(apiKey.previewName()).isEqualTo("preview_name") + assertThat(apiKey.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKey.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKey.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt index fbf9f7e4..dede2dfa 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt @@ -9,25 +9,18 @@ class ChatCompletionContentPartImageTest { @Test fun createChatCompletionContentPartImage() { - val chatCompletionContentPartImage = - ChatCompletionContentPartImage.builder() - .imageUrl( - ChatCompletionContentPartImage.ImageUrl.builder() - .url("url") - .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) - .build() - ) - .type(ChatCompletionContentPartImage.Type.IMAGE_URL) - .build() - assertThat(chatCompletionContentPartImage).isNotNull - assertThat(chatCompletionContentPartImage.imageUrl()) - .isEqualTo( - ChatCompletionContentPartImage.ImageUrl.builder() - .url("url") - .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) - .build() - ) - assertThat(chatCompletionContentPartImage.type()) - .isEqualTo(ChatCompletionContentPartImage.Type.IMAGE_URL) + val chatCompletionContentPartImage = ChatCompletionContentPartImage.builder() + .imageUrl(ChatCompletionContentPartImage.ImageUrl.builder() + .url("url") + .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) + .build()) + .type(ChatCompletionContentPartImage.Type.IMAGE_URL) + .build() + assertThat(chatCompletionContentPartImage).isNotNull + assertThat(chatCompletionContentPartImage.imageUrl()).isEqualTo(ChatCompletionContentPartImage.ImageUrl.builder() + .url("url") + .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) + .build()) + assertThat(chatCompletionContentPartImage.type()).isEqualTo(ChatCompletionContentPartImage.Type.IMAGE_URL) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt index 5e71c215..1ce72db0 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt @@ -9,14 +9,12 @@ class ChatCompletionContentPartTextTest { @Test fun createChatCompletionContentPartText() { - val chatCompletionContentPartText = - ChatCompletionContentPartText.builder() - .type(ChatCompletionContentPartText.Type.TEXT) - .text("text") - .build() - assertThat(chatCompletionContentPartText).isNotNull - assertThat(chatCompletionContentPartText.type()) - .isEqualTo(ChatCompletionContentPartText.Type.TEXT) - assertThat(chatCompletionContentPartText.text()).contains("text") + val chatCompletionContentPartText = ChatCompletionContentPartText.builder() + .type(ChatCompletionContentPartText.Type.TEXT) + .text("text") + .build() + assertThat(chatCompletionContentPartText).isNotNull + assertThat(chatCompletionContentPartText.type()).isEqualTo(ChatCompletionContentPartText.Type.TEXT) + assertThat(chatCompletionContentPartText.text()).contains("text") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt index c609ef38..f5079fc1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt @@ -9,27 +9,20 @@ class ChatCompletionMessageToolCallTest { @Test fun createChatCompletionMessageToolCall() { - val chatCompletionMessageToolCall = - ChatCompletionMessageToolCall.builder() - .id("id") - .function( - ChatCompletionMessageToolCall.Function.builder() - .arguments("arguments") - .name("name") - .build() - ) - .type(ChatCompletionMessageToolCall.Type.FUNCTION) - .build() - assertThat(chatCompletionMessageToolCall).isNotNull - assertThat(chatCompletionMessageToolCall.id()).isEqualTo("id") - assertThat(chatCompletionMessageToolCall.function()) - .isEqualTo( - ChatCompletionMessageToolCall.Function.builder() - .arguments("arguments") - .name("name") - .build() - ) - assertThat(chatCompletionMessageToolCall.type()) - .isEqualTo(ChatCompletionMessageToolCall.Type.FUNCTION) + val chatCompletionMessageToolCall = ChatCompletionMessageToolCall.builder() + .id("id") + .function(ChatCompletionMessageToolCall.Function.builder() + .arguments("arguments") + .name("name") + .build()) + .type(ChatCompletionMessageToolCall.Type.FUNCTION) + .build() + assertThat(chatCompletionMessageToolCall).isNotNull + assertThat(chatCompletionMessageToolCall.id()).isEqualTo("id") + assertThat(chatCompletionMessageToolCall.function()).isEqualTo(ChatCompletionMessageToolCall.Function.builder() + .arguments("arguments") + .name("name") + .build()) + assertThat(chatCompletionMessageToolCall.type()).isEqualTo(ChatCompletionMessageToolCall.Type.FUNCTION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt index 7cced6c5..cd737854 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt @@ -9,51 +9,34 @@ class CodeBundleTest { @Test fun createCodeBundle() { - val codeBundle = - CodeBundle.builder() - .bundleId("bundle_id") - .location( - CodeBundle.Location.Experiment.builder() - .evalName("eval_name") - .position( - CodeBundle.Location.Experiment.Position.Type.builder() - .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) - .build() - ) - .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) - .build() - ) - .runtimeContext( - CodeBundle.RuntimeContext.builder() - .runtime(CodeBundle.RuntimeContext.Runtime.NODE) - .version("version") - .build() - ) - .preview("preview") - .build() - assertThat(codeBundle).isNotNull - assertThat(codeBundle.bundleId()).isEqualTo("bundle_id") - assertThat(codeBundle.location()) - .isEqualTo( - CodeBundle.Location.ofExperiment( - CodeBundle.Location.Experiment.builder() - .evalName("eval_name") - .position( - CodeBundle.Location.Experiment.Position.Type.builder() - .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) - .build() - ) - .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) - .build() - ) - ) - assertThat(codeBundle.runtimeContext()) - .isEqualTo( - CodeBundle.RuntimeContext.builder() - .runtime(CodeBundle.RuntimeContext.Runtime.NODE) - .version("version") - .build() - ) - assertThat(codeBundle.preview()).contains("preview") + val codeBundle = CodeBundle.builder() + .bundleId("bundle_id") + .location(CodeBundle.Location.Experiment.builder() + .evalName("eval_name") + .position(CodeBundle.Location.Experiment.Position.Type.builder() + .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) + .build()) + .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) + .build()) + .runtimeContext(CodeBundle.RuntimeContext.builder() + .runtime(CodeBundle.RuntimeContext.Runtime.NODE) + .version("version") + .build()) + .preview("preview") + .build() + assertThat(codeBundle).isNotNull + assertThat(codeBundle.bundleId()).isEqualTo("bundle_id") + assertThat(codeBundle.location()).isEqualTo(CodeBundle.Location.ofExperiment(CodeBundle.Location.Experiment.builder() + .evalName("eval_name") + .position(CodeBundle.Location.Experiment.Position.Type.builder() + .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) + .build()) + .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) + .build())) + assertThat(codeBundle.runtimeContext()).isEqualTo(CodeBundle.RuntimeContext.builder() + .runtime(CodeBundle.RuntimeContext.Runtime.NODE) + .version("version") + .build()) + assertThat(codeBundle.preview()).contains("preview") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt index 6bfead25..12fa7a4c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt @@ -10,24 +10,22 @@ class CreateApiKeyOutputTest { @Test fun createCreateApiKeyOutput() { - val createApiKeyOutput = - CreateApiKeyOutput.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .key("key") - .name("name") - .previewName("preview_name") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(createApiKeyOutput).isNotNull - assertThat(createApiKeyOutput.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createApiKeyOutput.key()).isEqualTo("key") - assertThat(createApiKeyOutput.name()).isEqualTo("name") - assertThat(createApiKeyOutput.previewName()).isEqualTo("preview_name") - assertThat(createApiKeyOutput.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(createApiKeyOutput.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createApiKeyOutput.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val createApiKeyOutput = CreateApiKeyOutput.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .key("key") + .name("name") + .previewName("preview_name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(createApiKeyOutput).isNotNull + assertThat(createApiKeyOutput.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createApiKeyOutput.key()).isEqualTo("key") + assertThat(createApiKeyOutput.name()).isEqualTo("name") + assertThat(createApiKeyOutput.previewName()).isEqualTo("preview_name") + assertThat(createApiKeyOutput.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(createApiKeyOutput.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createApiKeyOutput.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt index 6ce8e5d3..e4af5d85 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt @@ -10,60 +10,26 @@ class CrossObjectInsertResponseTest { @Test fun createCrossObjectInsertResponse() { - val crossObjectInsertResponse = - CrossObjectInsertResponse.builder() - .dataset( - CrossObjectInsertResponse.Dataset.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - .experiment( - CrossObjectInsertResponse.Experiment.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - .projectLogs( - CrossObjectInsertResponse.ProjectLogs.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - .build() - assertThat(crossObjectInsertResponse).isNotNull - assertThat(crossObjectInsertResponse.dataset()) - .contains( - CrossObjectInsertResponse.Dataset.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - assertThat(crossObjectInsertResponse.experiment()) - .contains( - CrossObjectInsertResponse.Experiment.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - assertThat(crossObjectInsertResponse.projectLogs()) - .contains( - CrossObjectInsertResponse.ProjectLogs.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) + val crossObjectInsertResponse = CrossObjectInsertResponse.builder() + .dataset(CrossObjectInsertResponse.Dataset.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + .experiment(CrossObjectInsertResponse.Experiment.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + .projectLogs(CrossObjectInsertResponse.ProjectLogs.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + .build() + assertThat(crossObjectInsertResponse).isNotNull + assertThat(crossObjectInsertResponse.dataset()).contains(CrossObjectInsertResponse.Dataset.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + assertThat(crossObjectInsertResponse.experiment()).contains(CrossObjectInsertResponse.Experiment.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + assertThat(crossObjectInsertResponse.projectLogs()).contains(CrossObjectInsertResponse.ProjectLogs.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt index 4cc2a2db..2a0381cb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt @@ -9,8 +9,10 @@ class DataSummaryTest { @Test fun createDataSummary() { - val dataSummary = DataSummary.builder().totalRecords(0L).build() - assertThat(dataSummary).isNotNull - assertThat(dataSummary.totalRecords()).isEqualTo(0L) + val dataSummary = DataSummary.builder() + .totalRecords(0L) + .build() + assertThat(dataSummary).isNotNull + assertThat(dataSummary.totalRecords()).isEqualTo(0L) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index 53e0d257..506e2734 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -11,58 +11,49 @@ class DatasetCreateParamsTest { @Test fun create() { - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() + DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .build() } @Test fun body() { - val params = - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.description()).contains("description") - assertThat(body.metadata()) - .contains( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + val params = DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.description()).contains("description") + assertThat(body.metadata()).contains(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt index 8b41dbf4..b088a25f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt @@ -9,17 +9,20 @@ class DatasetDeleteParamsTest { @Test fun create() { - DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt index 687f05e1..d1168c6e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt @@ -11,60 +11,48 @@ class DatasetEventTest { @Test fun createDatasetEvent() { - val datasetEvent = - DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .origin( - DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .addTag("string") - .build() - assertThat(datasetEvent).isNotNull - assertThat(datasetEvent.id()).isEqualTo("id") - assertThat(datasetEvent._xactId()).isEqualTo("_xact_id") - assertThat(datasetEvent.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(datasetEvent.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(datasetEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(datasetEvent.rootSpanId()).isEqualTo("root_span_id") - assertThat(datasetEvent.spanId()).isEqualTo("span_id") - assertThat(datasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(datasetEvent.isRoot()).contains(true) - assertThat(datasetEvent.metadata()) - .contains( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(datasetEvent.origin()) - .contains( - DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - assertThat(datasetEvent.tags().get()).containsExactly("string") + val datasetEvent = DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .origin(DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .addTag("string") + .build() + assertThat(datasetEvent).isNotNull + assertThat(datasetEvent.id()).isEqualTo("id") + assertThat(datasetEvent._xactId()).isEqualTo("_xact_id") + assertThat(datasetEvent.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(datasetEvent.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(datasetEvent.spanId()).isEqualTo("span_id") + assertThat(datasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetEvent.isRoot()).contains(true) + assertThat(datasetEvent.metadata()).contains(DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(datasetEvent.origin()).contains(DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build()) + assertThat(datasetEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index 512fb176..f91d17c9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -11,91 +11,78 @@ class DatasetFeedbackParamsTest { @Test fun create() { - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - .build() + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - .build() + val params = DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder().id("id").build()) - .build() + val params = DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo(listOf(FeedbackDatasetItem.builder().id("id").build())) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackDatasetItem.builder() + .id("id") + .build())) } @Test fun getPathParam() { - val params = - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder().id("id").build()) - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .build()) + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt index 1a2a1725..83be2844 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt @@ -10,49 +10,50 @@ class DatasetFetchParamsTest { @Test fun create() { - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun queryParams() { - val params = - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("limit", "0") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index 3120e7e1..ab4d88d8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -10,60 +10,57 @@ class DatasetFetchPostParamsTest { @Test fun create() { - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun body() { - val params = - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + val params = DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.cursor()).contains("cursor") - assertThat(body.limit()).contains(0L) - assertThat(body.maxRootSpanId()).contains("max_root_span_id") - assertThat(body.maxXactId()).contains("max_xact_id") - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index 9f080dd0..d0c459e2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -12,114 +12,96 @@ class DatasetInsertParamsTest { @Test fun create() { - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + val params = DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()) - .isEqualTo( - listOf( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder().build()) - .build() + val params = DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder().build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) } @Test fun getPathParam() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder().build()) - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder().build()) + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index de58fd44..e3a35955 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -10,50 +10,46 @@ class DatasetListParamsTest { @Test fun create() { - DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetListParams.builder() + .datasetName("dataset_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("dataset_name", "dataset_name") - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetListParams.builder() + .datasetName("dataset_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("dataset_name", "dataset_name") + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = DatasetListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt index 95326568..8473c6ff 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt @@ -9,19 +9,20 @@ class DatasetRetrieveParamsTest { @Test fun create() { - DatasetRetrieveParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt index 83303cf0..d2073c3f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt @@ -10,44 +10,41 @@ class DatasetSummarizeParamsTest { @Test fun create() { - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() } @Test fun queryParams() { - val params = - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - val expected = QueryParams.builder() - expected.put("summarize_data", "true") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() + val expected = QueryParams.builder() + expected.put("summarize_data", "true") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt index 829a918e..5c0ada06 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt @@ -11,34 +11,28 @@ class DatasetTest { @Test fun createDataset() { - val dataset = - Dataset.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata( - Dataset.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(dataset).isNotNull - assertThat(dataset.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(dataset.name()).isEqualTo("name") - assertThat(dataset.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(dataset.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset.description()).contains("description") - assertThat(dataset.metadata()) - .contains( - Dataset.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(dataset.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val dataset = Dataset.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .metadata(Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(dataset).isNotNull + assertThat(dataset.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(dataset.name()).isEqualTo("name") + assertThat(dataset.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(dataset.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.description()).contains("description") + assertThat(dataset.metadata()).contains(Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(dataset.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt index c7976ff2..4b84f951 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt @@ -11,63 +11,57 @@ class DatasetUpdateParamsTest { @Test fun create() { - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .build() } @Test fun body() { - val params = - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() + val params = DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.description()).contains("description") - assertThat(body.metadata()) - .contains( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.name()).contains("name") + assertNotNull(body) + assertThat(body.description()).contains("description") + assertThat(body.metadata()).contains(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.name()).contains("name") } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt index d5e8e9f1..f901f36e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt @@ -10,47 +10,45 @@ class EnvVarCreateParamsTest { @Test fun create() { - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() + EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build() } @Test fun body() { - val params = - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) - assertThat(body.value()).contains("value") + val params = EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) + assertThat(body.value()).contains("value") } @Test fun bodyWithoutOptionalFields() { - val params = - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) + val params = EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt index b6264f9d..6808443f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt @@ -9,17 +9,20 @@ class EnvVarDeleteParamsTest { @Test fun create() { - EnvVarDeleteParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - EnvVarDeleteParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "envVarId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "envVarId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListParamsTest.kt index 4af4a47a..1d3b4b4f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListParamsTest.kt @@ -10,41 +10,37 @@ class EnvVarListParamsTest { @Test fun create() { - EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() + EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build() } @Test fun queryParams() { - val params = - EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("env_var_name", "env_var_name") - expected.put( - "ids", - EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", EnvVarListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("env_var_name", "env_var_name") + expected.put("ids", EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", EnvVarListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = EnvVarListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = EnvVarListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt index 35b86df1..4e695e38 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt @@ -10,30 +10,24 @@ class EnvVarListResponseTest { @Test fun createEnvVarListResponse() { - val envVarListResponse = - EnvVarListResponse.builder() - .addObject( - EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(envVarListResponse).isNotNull - assertThat(envVarListResponse.objects()) - .containsExactly( - EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) + val envVarListResponse = EnvVarListResponse.builder() + .addObject(EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build()) + .build() + assertThat(envVarListResponse).isNotNull + assertThat(envVarListResponse.objects()).containsExactly(EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt index 68d9ebd2..53857e16 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt @@ -10,47 +10,45 @@ class EnvVarReplaceParamsTest { @Test fun create() { - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() + EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build() } @Test fun body() { - val params = - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) - assertThat(body.value()).contains("value") + val params = EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) + assertThat(body.value()).contains("value") } @Test fun bodyWithoutOptionalFields() { - val params = - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) + val params = EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt index bca82bdc..513ce8d5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class EnvVarRetrieveParamsTest { @Test fun create() { - EnvVarRetrieveParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - EnvVarRetrieveParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "envVarId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "envVarId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt index 224dddbb..f7825f39 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt @@ -10,21 +10,20 @@ class EnvVarTest { @Test fun createEnvVar() { - val envVar = - EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - assertThat(envVar).isNotNull - assertThat(envVar.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(envVar.name()).isEqualTo("name") - assertThat(envVar.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(envVar.objectType()).isEqualTo(EnvVar.ObjectType.ORGANIZATION) - assertThat(envVar.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(envVar.used()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + val envVar = EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(envVar).isNotNull + assertThat(envVar.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(envVar.name()).isEqualTo("name") + assertThat(envVar.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(envVar.objectType()).isEqualTo(EnvVar.ObjectType.ORGANIZATION) + assertThat(envVar.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(envVar.used()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt index e4ad1080..7188655e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt @@ -10,54 +10,51 @@ class EnvVarUpdateParamsTest { @Test fun create() { - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() + EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build() } @Test fun body() { - val params = - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.value()).contains("value") + val params = EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.value()).contains("value") } @Test fun bodyWithoutOptionalFields() { - val params = - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .build() + val params = EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } @Test fun getPathParam() { - val params = - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .build() - assertThat(params).isNotNull - // path param "envVarId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + assertThat(params).isNotNull + // path param "envVarId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index 5ac72887..3381511b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -11,212 +11,161 @@ class EvalCreateParamsTest { @Test fun create() { - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .task( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - .isPublic(true) - .maxConcurrency(0.0) - .metadata( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() + EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + .isPublic(true) + .maxConcurrency(0.0) + .metadata(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build() } @Test fun body() { - val params = - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .task( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - .isPublic(true) - .maxConcurrency(0.0) - .metadata( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() + val params = EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + .isPublic(true) + .maxConcurrency(0.0) + .metadata(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.data()) - .isEqualTo( - EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() - ) - ) - assertThat(body.projectId()).isEqualTo("project_id") - assertThat(body.scores()) - .isEqualTo( - listOf( - EvalCreateParams.Score.ofFunctionId( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - ) - ) - assertThat(body.task()) - .isEqualTo( - EvalCreateParams.Task.ofFunctionId( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - ) - assertThat(body.baseExperimentId()).contains("base_experiment_id") - assertThat(body.baseExperimentName()).contains("base_experiment_name") - assertThat(body.experimentName()).contains("experiment_name") - assertThat(body.gitMetadataSettings()) - .contains( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - assertThat(body.isPublic()).contains(true) - assertThat(body.maxConcurrency()).contains(0.0) - assertThat(body.metadata()) - .contains( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.repoInfo()) - .contains( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - assertThat(body.stream()).contains(true) - assertThat(body.timeout()).contains(0.0) - assertThat(body.trialCount()).contains(0.0) + assertNotNull(body) + assertThat(body.data()).isEqualTo(EvalCreateParams.Data.ofDatasetId(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build())) + assertThat(body.projectId()).isEqualTo("project_id") + assertThat(body.scores()).isEqualTo(listOf(EvalCreateParams.Score.ofFunctionId(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()))) + assertThat(body.task()).isEqualTo(EvalCreateParams.Task.ofFunctionId(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build())) + assertThat(body.baseExperimentId()).contains("base_experiment_id") + assertThat(body.baseExperimentName()).contains("base_experiment_name") + assertThat(body.experimentName()).contains("experiment_name") + assertThat(body.gitMetadataSettings()).contains(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + assertThat(body.isPublic()).contains(true) + assertThat(body.maxConcurrency()).contains(0.0) + assertThat(body.metadata()).contains(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.repoInfo()).contains(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + assertThat(body.stream()).contains(true) + assertThat(body.timeout()).contains(0.0) + assertThat(body.trialCount()).contains(0.0) } @Test fun bodyWithoutOptionalFields() { - val params = - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder().functionId("function_id").build() - ) - .task(EvalCreateParams.Task.FunctionId.builder().functionId("function_id").build()) - .build() + val params = EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.data()) - .isEqualTo( - EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() - ) - ) - assertThat(body.projectId()).isEqualTo("project_id") - assertThat(body.scores()) - .isEqualTo( - listOf( - EvalCreateParams.Score.ofFunctionId( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .build() - ) - ) - ) - assertThat(body.task()) - .isEqualTo( - EvalCreateParams.Task.ofFunctionId( - EvalCreateParams.Task.FunctionId.builder().functionId("function_id").build() - ) - ) + assertNotNull(body) + assertThat(body.data()).isEqualTo(EvalCreateParams.Data.ofDatasetId(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build())) + assertThat(body.projectId()).isEqualTo("project_id") + assertThat(body.scores()).isEqualTo(listOf(EvalCreateParams.Score.ofFunctionId(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .build()))) + assertThat(body.task()).isEqualTo(EvalCreateParams.Task.ofFunctionId(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .build())) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index 0b43f784..95de1502 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -11,111 +11,95 @@ class ExperimentCreateParamsTest { @Test fun create() { - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("x") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("x") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build() } @Test fun body() { - val params = - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("x") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() + val params = ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("x") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).contains("dataset_version") - assertThat(body.description()).contains("description") - assertThat(body.ensureNew()).contains(true) - assertThat(body.metadata()) - .contains( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.name()).contains("x") - assertThat(body.public_()).contains(true) - assertThat(body.repoInfo()) - .contains( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) + assertNotNull(body) + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).contains("dataset_version") + assertThat(body.description()).contains("description") + assertThat(body.ensureNew()).contains(true) + assertThat(body.metadata()).contains(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.name()).contains("x") + assertThat(body.public_()).contains(true) + assertThat(body.repoInfo()).contains(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt index 30220ebc..6a49fc3d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt @@ -9,21 +9,20 @@ class ExperimentDeleteParamsTest { @Test fun create() { - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt index 3830f18c..34834679 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt @@ -11,124 +11,100 @@ class ExperimentEventTest { @Test fun createExperimentEvent() { - val experimentEvent = - ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .addSpanParent("string") - .addTag("string") - .build() - assertThat(experimentEvent).isNotNull - assertThat(experimentEvent.id()).isEqualTo("id") - assertThat(experimentEvent._xactId()).isEqualTo("_xact_id") - assertThat(experimentEvent.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experimentEvent.experimentId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experimentEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experimentEvent.rootSpanId()).isEqualTo("root_span_id") - assertThat(experimentEvent.spanId()).isEqualTo("span_id") - assertThat(experimentEvent.context()) - .contains( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - assertThat(experimentEvent.datasetRecordId()).contains("dataset_record_id") - assertThat(experimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent.isRoot()).contains(true) - assertThat(experimentEvent.metadata()) - .contains( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(experimentEvent.metrics()) - .contains( - ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - assertThat(experimentEvent.origin()) - .contains( - ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent.scores()) - .contains( - ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(experimentEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) - assertThat(experimentEvent.spanParents().get()).containsExactly("string") - assertThat(experimentEvent.tags().get()).containsExactly("string") + val experimentEvent = ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build() + assertThat(experimentEvent).isNotNull + assertThat(experimentEvent.id()).isEqualTo("id") + assertThat(experimentEvent._xactId()).isEqualTo("_xact_id") + assertThat(experimentEvent.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experimentEvent.experimentId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experimentEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experimentEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(experimentEvent.spanId()).isEqualTo("span_id") + assertThat(experimentEvent.context()).contains(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + assertThat(experimentEvent.datasetRecordId()).contains("dataset_record_id") + assertThat(experimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.isRoot()).contains(true) + assertThat(experimentEvent.metadata()).contains(ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(experimentEvent.metrics()).contains(ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + assertThat(experimentEvent.origin()).contains(ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build()) + assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.scores()).contains(ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(experimentEvent.spanAttributes()).contains(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + assertThat(experimentEvent.spanParents().get()).containsExactly("string") + assertThat(experimentEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index edb22bd0..99065209 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -11,109 +11,90 @@ class ExperimentFeedbackParamsTest { @Test fun create() { - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - .build() + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - .build() + val params = ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder().id("id").build()) - .build() + val params = ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo(listOf(FeedbackExperimentItem.builder().id("id").build())) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackExperimentItem.builder() + .id("id") + .build())) } @Test fun getPathParam() { - val params = - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder().id("id").build()) - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .build()) + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt index a699676d..b782831e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt @@ -10,53 +10,50 @@ class ExperimentFetchParamsTest { @Test fun create() { - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun queryParams() { - val params = - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("limit", "0") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index f537a14a..001acc2f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -10,60 +10,57 @@ class ExperimentFetchPostParamsTest { @Test fun create() { - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun body() { - val params = - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + val params = ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.cursor()).contains("cursor") - assertThat(body.limit()).contains(0L) - assertThat(body.maxRootSpanId()).contains("max_root_span_id") - assertThat(body.maxXactId()).contains("max_xact_id") - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt index 9627ff9b..89d62de4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt @@ -12,210 +12,171 @@ class ExperimentInsertParamsTest { @Test fun create() { - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + val params = ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()) - .isEqualTo( - listOf( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder().build()) - .build() + val params = ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder().build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) } @Test fun getPathParam() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder().build()) - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder().build()) + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 06a265e5..9e8221f4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -10,50 +10,46 @@ class ExperimentListParamsTest { @Test fun create() { - ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .experimentName("experiment_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("experiment_name", "experiment_name") - expected.put( - "ids", - ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .experimentName("experiment_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("experiment_name", "experiment_name") + expected.put("ids", ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ExperimentListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt index b9530a24..7a6cd8f1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class ExperimentRetrieveParamsTest { @Test fun create() { - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt index 257ca247..02307eab 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt @@ -10,47 +10,44 @@ class ExperimentSummarizeParamsTest { @Test fun create() { - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() } @Test fun queryParams() { - val params = - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - val expected = QueryParams.builder() - expected.put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("summarize_scores", "true") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() + val expected = QueryParams.builder() + expected.put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("summarize_scores", "true") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt index 2d2df4e3..4fa1b102 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt @@ -11,72 +11,60 @@ class ExperimentTest { @Test fun createExperiment() { - val experiment = - Experiment.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .public_(true) - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .commit("commit") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata( - Experiment.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(experiment).isNotNull - assertThat(experiment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.name()).isEqualTo("name") - assertThat(experiment.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.public_()).isEqualTo(true) - assertThat(experiment.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.commit()).contains("commit") - assertThat(experiment.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experiment.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.datasetVersion()).contains("dataset_version") - assertThat(experiment.deletedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experiment.description()).contains("description") - assertThat(experiment.metadata()) - .contains( - Experiment.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(experiment.repoInfo()) - .contains( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - assertThat(experiment.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val experiment = Experiment.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .public_(true) + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit("commit") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .metadata(Experiment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(experiment).isNotNull + assertThat(experiment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.name()).isEqualTo("name") + assertThat(experiment.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.public_()).isEqualTo(true) + assertThat(experiment.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.commit()).contains("commit") + assertThat(experiment.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experiment.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.datasetVersion()).contains("dataset_version") + assertThat(experiment.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experiment.description()).contains("description") + assertThat(experiment.metadata()).contains(Experiment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(experiment.repoInfo()).contains(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + assertThat(experiment.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt index e7ed2b95..7abf3e9b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt @@ -11,119 +11,102 @@ class ExperimentUpdateParamsTest { @Test fun create() { - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build() } @Test fun body() { - val params = - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() + val params = ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).contains("dataset_version") - assertThat(body.description()).contains("description") - assertThat(body.metadata()) - .contains( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.name()).contains("name") - assertThat(body.public_()).contains(true) - assertThat(body.repoInfo()) - .contains( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) + assertNotNull(body) + assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).contains("dataset_version") + assertThat(body.description()).contains("description") + assertThat(body.metadata()).contains(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.name()).contains("name") + assertThat(body.public_()).contains(true) + assertThat(body.repoInfo()).contains(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt index 6543fca7..b803ec6d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -10,28 +10,22 @@ class FeedbackDatasetItemTest { @Test fun createFeedbackDatasetItem() { - val feedbackDatasetItem = - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - assertThat(feedbackDatasetItem).isNotNull - assertThat(feedbackDatasetItem.id()).isEqualTo("id") - assertThat(feedbackDatasetItem.comment()).contains("comment") - assertThat(feedbackDatasetItem.metadata()) - .contains( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) - assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") + val feedbackDatasetItem = FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() + assertThat(feedbackDatasetItem).isNotNull + assertThat(feedbackDatasetItem.id()).isEqualTo("id") + assertThat(feedbackDatasetItem.comment()).contains("comment") + assertThat(feedbackDatasetItem.metadata()).contains(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) + assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt index eef4dee8..f1fda957 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -10,42 +10,30 @@ class FeedbackExperimentItemTest { @Test fun createFeedbackExperimentItem() { - val feedbackExperimentItem = - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - assertThat(feedbackExperimentItem).isNotNull - assertThat(feedbackExperimentItem.id()).isEqualTo("id") - assertThat(feedbackExperimentItem.comment()).contains("comment") - assertThat(feedbackExperimentItem._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(feedbackExperimentItem.metadata()) - .contains( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(feedbackExperimentItem.scores()) - .contains( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) - assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") + val feedbackExperimentItem = FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() + assertThat(feedbackExperimentItem).isNotNull + assertThat(feedbackExperimentItem.id()).isEqualTo("id") + assertThat(feedbackExperimentItem.comment()).contains("comment") + assertThat(feedbackExperimentItem._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackExperimentItem.metadata()).contains(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(feedbackExperimentItem.scores()).contains(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) + assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt index 34f44497..69d0d47b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -10,42 +10,30 @@ class FeedbackProjectLogsItemTest { @Test fun createFeedbackProjectLogsItem() { - val feedbackProjectLogsItem = - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - assertThat(feedbackProjectLogsItem).isNotNull - assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") - assertThat(feedbackProjectLogsItem.comment()).contains("comment") - assertThat(feedbackProjectLogsItem._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(feedbackProjectLogsItem.metadata()) - .contains( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(feedbackProjectLogsItem.scores()) - .contains( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) - assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") + val feedbackProjectLogsItem = FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() + assertThat(feedbackProjectLogsItem).isNotNull + assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") + assertThat(feedbackProjectLogsItem.comment()).contains("comment") + assertThat(feedbackProjectLogsItem._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackProjectLogsItem.metadata()).contains(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(feedbackProjectLogsItem.scores()).contains(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) + assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt index a1b62a0b..daebb6ba 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt @@ -9,9 +9,10 @@ class FeedbackResponseSchemaTest { @Test fun createFeedbackResponseSchema() { - val feedbackResponseSchema = - FeedbackResponseSchema.builder().status(FeedbackResponseSchema.Status.SUCCESS).build() - assertThat(feedbackResponseSchema).isNotNull - assertThat(feedbackResponseSchema.status()).isEqualTo(FeedbackResponseSchema.Status.SUCCESS) + val feedbackResponseSchema = FeedbackResponseSchema.builder() + .status(FeedbackResponseSchema.Status.SUCCESS) + .build() + assertThat(feedbackResponseSchema).isNotNull + assertThat(feedbackResponseSchema.status()).isEqualTo(FeedbackResponseSchema.Status.SUCCESS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt index ad7d703b..7017147f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt @@ -11,68 +11,54 @@ class FetchDatasetEventsResponseTest { @Test fun createFetchDatasetEventsResponse() { - val fetchDatasetEventsResponse = - FetchDatasetEventsResponse.builder() - .addEvent( - DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .origin( - DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .addTag("string") - .build() - ) - .cursor("cursor") - .build() - assertThat(fetchDatasetEventsResponse).isNotNull - assertThat(fetchDatasetEventsResponse.events()) - .containsExactly( - DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .origin( - DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .addTag("string") - .build() - ) - assertThat(fetchDatasetEventsResponse.cursor()).contains("cursor") + val fetchDatasetEventsResponse = FetchDatasetEventsResponse.builder() + .addEvent(DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .origin(DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .addTag("string") + .build()) + .cursor("cursor") + .build() + assertThat(fetchDatasetEventsResponse).isNotNull + assertThat(fetchDatasetEventsResponse.events()).containsExactly(DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .origin(DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .addTag("string") + .build()) + assertThat(fetchDatasetEventsResponse.cursor()).contains("cursor") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt index 7e95ce35..fd2b1539 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt @@ -11,133 +11,106 @@ class FetchExperimentEventsResponseTest { @Test fun createFetchExperimentEventsResponse() { - val fetchExperimentEventsResponse = - FetchExperimentEventsResponse.builder() - .addEvent( - ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .addSpanParent("string") - .addTag("string") - .build() - ) - .cursor("cursor") - .build() - assertThat(fetchExperimentEventsResponse).isNotNull - assertThat(fetchExperimentEventsResponse.events()) - .containsExactly( - ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .addSpanParent("string") - .addTag("string") - .build() - ) - assertThat(fetchExperimentEventsResponse.cursor()).contains("cursor") + val fetchExperimentEventsResponse = FetchExperimentEventsResponse.builder() + .addEvent(ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build()) + .cursor("cursor") + .build() + assertThat(fetchExperimentEventsResponse).isNotNull + assertThat(fetchExperimentEventsResponse.events()).containsExactly(ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build()) + assertThat(fetchExperimentEventsResponse.cursor()).contains("cursor") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt index 4c35853e..e99c2e4e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt @@ -11,133 +11,106 @@ class FetchProjectLogsEventsResponseTest { @Test fun createFetchProjectLogsEventsResponse() { - val fetchProjectLogsEventsResponse = - FetchProjectLogsEventsResponse.builder() - .addEvent( - ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .addSpanParent("string") - .addTag("string") - .build() - ) - .cursor("cursor") - .build() - assertThat(fetchProjectLogsEventsResponse).isNotNull - assertThat(fetchProjectLogsEventsResponse.events()) - .containsExactly( - ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .addSpanParent("string") - .addTag("string") - .build() - ) - assertThat(fetchProjectLogsEventsResponse.cursor()).contains("cursor") + val fetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse.builder() + .addEvent(ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build()) + .cursor("cursor") + .build() + assertThat(fetchProjectLogsEventsResponse).isNotNull + assertThat(fetchProjectLogsEventsResponse.events()).containsExactly(ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build()) + assertThat(fetchProjectLogsEventsResponse.cursor()).contains("cursor") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt index f4114dc7..19b3364c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt @@ -11,351 +11,216 @@ class FunctionCreateParamsTest { @Test fun create() { - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()) - .isEqualTo( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionSchema()) - .contains( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - assertThat(body.functionType()).contains(FunctionCreateParams.FunctionType.LLM) - assertThat(body.origin()) - .contains( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.functionData()).isEqualTo(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionSchema()).contains(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + assertThat(body.functionType()).contains(FunctionCreateParams.FunctionType.LLM) + assertThat(body.origin()).contains(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()) - .isEqualTo( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.functionData()).isEqualTo(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt index 480affa6..0ddf31ef 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt @@ -9,19 +9,20 @@ class FunctionDeleteParamsTest { @Test fun create() { - FunctionDeleteParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index dcfb6ecc..d494cacb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -11,146 +11,105 @@ class FunctionInvokeParamsTest { @Test fun create() { - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - .stream(true) - .version("version") - .build() + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build()) + .stream(true) + .version("version") + .build() } @Test fun body() { - val params = - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - .stream(true) - .version("version") - .build() + val params = FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build()) + .stream(true) + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body.messages()) - .contains( - listOf( - FunctionInvokeParams.Message.ofSystem( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - ) - ) - assertThat(body.mode()).contains(FunctionInvokeParams.Mode.AUTO) - assertThat(body.parent()) - .contains( - FunctionInvokeParams.Parent.ofSpanParentStruct( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - ) - assertThat(body.stream()).contains(true) - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.messages()).contains(listOf(FunctionInvokeParams.Message.ofSystem(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()))) + assertThat(body.mode()).contains(FunctionInvokeParams.Mode.AUTO) + assertThat(body.parent()).contains(FunctionInvokeParams.Parent.ofSpanParentStruct(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build())) + assertThat(body.stream()).contains(true) + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index 289b3695..4838dff0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -10,56 +10,52 @@ class FunctionListParamsTest { @Test fun create() { - FunctionListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .functionName("function_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() + FunctionListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .functionName("function_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() } @Test fun queryParams() { - val params = - FunctionListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .functionName("function_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("function_name", "function_name") - expected.put( - "ids", - FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("slug", "slug") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = FunctionListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .functionName("function_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("function_name", "function_name") + expected.put("ids", FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("slug", "slug") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = FunctionListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = FunctionListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt index 56eba313..6e455332 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt @@ -11,351 +11,216 @@ class FunctionReplaceParamsTest { @Test fun create() { - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()) - .isEqualTo( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionSchema()) - .contains( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - assertThat(body.functionType()).contains(FunctionReplaceParams.FunctionType.LLM) - assertThat(body.origin()) - .contains( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.functionData()).isEqualTo(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionSchema()).contains(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + assertThat(body.functionType()).contains(FunctionReplaceParams.FunctionType.LLM) + assertThat(body.origin()).contains(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()) - .isEqualTo( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.functionData()).isEqualTo(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt index 95d6777e..29b1b68a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt @@ -9,19 +9,20 @@ class FunctionRetrieveParamsTest { @Test fun create() { - FunctionRetrieveParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt index b6570597..65ad88e1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt @@ -11,234 +11,142 @@ class FunctionTest { @Test fun createFunction() { - val function = - Function.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("_xact_id") - .functionData( - Function.FunctionData.Prompt.builder() - .type(Function.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .logId(Function.LogId.P) - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .functionSchema( - Function.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(Function.FunctionType.LLM) - .metadata( - Function.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .origin( - Function.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - assertThat(function).isNotNull - assertThat(function.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(function._xactId()).isEqualTo("_xact_id") - assertThat(function.functionData()) - .isEqualTo( - Function.FunctionData.ofPrompt( - Function.FunctionData.Prompt.builder() - .type(Function.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(function.logId()).isEqualTo(Function.LogId.P) - assertThat(function.name()).isEqualTo("name") - assertThat(function.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(function.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(function.slug()).isEqualTo("slug") - assertThat(function.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(function.description()).contains("description") - assertThat(function.functionSchema()) - .contains( - Function.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - assertThat(function.functionType()).contains(Function.FunctionType.LLM) - assertThat(function.metadata()) - .contains( - Function.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(function.origin()) - .contains( - Function.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - assertThat(function.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(function.tags().get()).containsExactly("string") + val function = Function.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._xactId("_xact_id") + .functionData(Function.FunctionData.Prompt.builder() + .type(Function.FunctionData.Prompt.Type.PROMPT) + .build()) + .logId(Function.LogId.P) + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .functionSchema(Function.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(Function.FunctionType.LLM) + .metadata(Function.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .origin(Function.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Function.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() + assertThat(function).isNotNull + assertThat(function.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function._xactId()).isEqualTo("_xact_id") + assertThat(function.functionData()).isEqualTo(Function.FunctionData.ofPrompt(Function.FunctionData.Prompt.builder() + .type(Function.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(function.logId()).isEqualTo(Function.LogId.P) + assertThat(function.name()).isEqualTo("name") + assertThat(function.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function.slug()).isEqualTo("slug") + assertThat(function.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(function.description()).contains("description") + assertThat(function.functionSchema()).contains(Function.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + assertThat(function.functionType()).contains(Function.FunctionType.LLM) + assertThat(function.metadata()).contains(Function.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(function.origin()).contains(Function.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Function.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + assertThat(function.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(function.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index 051c89be..e88bb07d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -11,298 +11,183 @@ class FunctionUpdateParamsTest { @Test fun create() { - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.description()).contains("description") - assertThat(body.functionData()) - .contains( - FunctionUpdateParams.FunctionData.ofPrompt( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).contains("name") - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.description()).contains("description") + assertThat(body.functionData()).contains(FunctionUpdateParams.FunctionData.ofPrompt(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).contains("name") + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index c9d71536..e4be7a89 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -10,43 +10,44 @@ class GroupCreateParamsTest { @Test fun create() { - GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = - GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = GroupCreateParams.builder().name("x").build() + val params = GroupCreateParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt index e7f479a6..db4190e4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt @@ -9,17 +9,20 @@ class GroupDeleteParamsTest { @Test fun create() { - GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + GroupDeleteParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = GroupDeleteParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index c5cd5eb4..53ff9db9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -10,44 +10,40 @@ class GroupListParamsTest { @Test fun create() { - GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("group_name", "group_name") - expected.put( - "ids", - GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("group_name", "group_name") + expected.put("ids", GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = GroupListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = GroupListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index 093c89bc..1e04ba8f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -10,43 +10,44 @@ class GroupReplaceParamsTest { @Test fun create() { - GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = - GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = GroupReplaceParams.builder().name("x").build() + val params = GroupReplaceParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt index 289d5b88..b86977bd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class GroupRetrieveParamsTest { @Test fun create() { - GroupRetrieveParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - GroupRetrieveParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt index 1acccdaa..476f11a1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt @@ -10,29 +10,26 @@ class GroupTest { @Test fun createGroup() { - val group = - Group.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(group).isNotNull - assertThat(group.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.name()).isEqualTo("name") - assertThat(group.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(group.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(group.description()).contains("description") - assertThat(group.memberGroups().get()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.memberUsers().get()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val group = Group.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(group).isNotNull + assertThat(group.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.name()).isEqualTo("name") + assertThat(group.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(group.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(group.description()).contains("description") + assertThat(group.memberGroups().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.memberUsers().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index cb449a6e..46d425b2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -10,61 +10,60 @@ class GroupUpdateParamsTest { @Test fun create() { - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.addMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.addMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("x") - assertThat(body.removeMemberGroups()) - .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.removeMemberUsers()) - .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertNotNull(body) + assertThat(body.addMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.addMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("x") + assertThat(body.removeMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.removeMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun bodyWithoutOptionalFields() { - val params = - GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt index 53366aec..bc3c26de 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt @@ -11,45 +11,38 @@ class InsertDatasetEventTest { @Test fun createInsertDatasetEvent() { - val insertDatasetEvent = - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - assertThat(insertDatasetEvent).isNotNull - assertThat(insertDatasetEvent.id()).contains("id") - assertThat(insertDatasetEvent._isMerge()).contains(true) - assertThat(insertDatasetEvent._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertDatasetEvent._objectDelete()).contains(true) - assertThat(insertDatasetEvent._parentId()).contains("_parent_id") - assertThat(insertDatasetEvent.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertDatasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEvent.metadata()) - .contains( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") - assertThat(insertDatasetEvent.spanId()).contains("span_id") - assertThat(insertDatasetEvent.spanParents().get()).containsExactly("string") - assertThat(insertDatasetEvent.tags().get()).containsExactly("string") + val insertDatasetEvent = InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + assertThat(insertDatasetEvent).isNotNull + assertThat(insertDatasetEvent.id()).contains("id") + assertThat(insertDatasetEvent._isMerge()).contains(true) + assertThat(insertDatasetEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertDatasetEvent._objectDelete()).contains(true) + assertThat(insertDatasetEvent._parentId()).contains("_parent_id") + assertThat(insertDatasetEvent.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertDatasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEvent.metadata()).contains(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") + assertThat(insertDatasetEvent.spanId()).contains("span_id") + assertThat(insertDatasetEvent.spanParents().get()).containsExactly("string") + assertThat(insertDatasetEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt index 96d2a732..32730c21 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt @@ -9,8 +9,10 @@ class InsertEventsResponseTest { @Test fun createInsertEventsResponse() { - val insertEventsResponse = InsertEventsResponse.builder().addRowId("string").build() - assertThat(insertEventsResponse).isNotNull - assertThat(insertEventsResponse.rowIds()).containsExactly("string") + val insertEventsResponse = InsertEventsResponse.builder() + .addRowId("string") + .build() + assertThat(insertEventsResponse).isNotNull + assertThat(insertEventsResponse.rowIds()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt index e9425570..5135be62 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt @@ -11,108 +11,88 @@ class InsertExperimentEventTest { @Test fun createInsertExperimentEvent() { - val insertExperimentEvent = - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - assertThat(insertExperimentEvent).isNotNull - assertThat(insertExperimentEvent.id()).contains("id") - assertThat(insertExperimentEvent._isMerge()).contains(true) - assertThat(insertExperimentEvent._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertExperimentEvent._objectDelete()).contains(true) - assertThat(insertExperimentEvent._parentId()).contains("_parent_id") - assertThat(insertExperimentEvent.context()) - .contains( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - assertThat(insertExperimentEvent.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") - assertThat(insertExperimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent.metadata()) - .contains( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(insertExperimentEvent.metrics()) - .contains( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - assertThat(insertExperimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") - assertThat(insertExperimentEvent.scores()) - .contains( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(insertExperimentEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) - assertThat(insertExperimentEvent.spanId()).contains("span_id") - assertThat(insertExperimentEvent.spanParents().get()).containsExactly("string") - assertThat(insertExperimentEvent.tags().get()).containsExactly("string") + val insertExperimentEvent = InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + assertThat(insertExperimentEvent).isNotNull + assertThat(insertExperimentEvent.id()).contains("id") + assertThat(insertExperimentEvent._isMerge()).contains(true) + assertThat(insertExperimentEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertExperimentEvent._objectDelete()).contains(true) + assertThat(insertExperimentEvent._parentId()).contains("_parent_id") + assertThat(insertExperimentEvent.context()).contains(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + assertThat(insertExperimentEvent.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") + assertThat(insertExperimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent.metadata()).contains(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(insertExperimentEvent.metrics()).contains(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + assertThat(insertExperimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") + assertThat(insertExperimentEvent.scores()).contains(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(insertExperimentEvent.spanAttributes()).contains(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + assertThat(insertExperimentEvent.spanId()).contains("span_id") + assertThat(insertExperimentEvent.spanParents().get()).containsExactly("string") + assertThat(insertExperimentEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt index 3454b8e9..203cd955 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt @@ -11,106 +11,86 @@ class InsertProjectLogsEventTest { @Test fun createInsertProjectLogsEvent() { - val insertProjectLogsEvent = - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - assertThat(insertProjectLogsEvent).isNotNull - assertThat(insertProjectLogsEvent.id()).contains("id") - assertThat(insertProjectLogsEvent._isMerge()).contains(true) - assertThat(insertProjectLogsEvent._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertProjectLogsEvent._objectDelete()).contains(true) - assertThat(insertProjectLogsEvent._parentId()).contains("_parent_id") - assertThat(insertProjectLogsEvent.context()) - .contains( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - assertThat(insertProjectLogsEvent.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertProjectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent.metadata()) - .contains( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(insertProjectLogsEvent.metrics()) - .contains( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") - assertThat(insertProjectLogsEvent.scores()) - .contains( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(insertProjectLogsEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) - assertThat(insertProjectLogsEvent.spanId()).contains("span_id") - assertThat(insertProjectLogsEvent.spanParents().get()).containsExactly("string") - assertThat(insertProjectLogsEvent.tags().get()).containsExactly("string") + val insertProjectLogsEvent = InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + assertThat(insertProjectLogsEvent).isNotNull + assertThat(insertProjectLogsEvent.id()).contains("id") + assertThat(insertProjectLogsEvent._isMerge()).contains(true) + assertThat(insertProjectLogsEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertProjectLogsEvent._objectDelete()).contains(true) + assertThat(insertProjectLogsEvent._parentId()).contains("_parent_id") + assertThat(insertProjectLogsEvent.context()).contains(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + assertThat(insertProjectLogsEvent.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertProjectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent.metadata()).contains(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(insertProjectLogsEvent.metrics()).contains(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") + assertThat(insertProjectLogsEvent.scores()).contains(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(insertProjectLogsEvent.spanAttributes()).contains(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + assertThat(insertProjectLogsEvent.spanId()).contains("span_id") + assertThat(insertProjectLogsEvent.spanParents().get()).containsExactly("string") + assertThat(insertProjectLogsEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt index cc848c7c..df3be6e7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt @@ -9,21 +9,20 @@ class MetricSummaryTest { @Test fun createMetricSummary() { - val metricSummary = - MetricSummary.builder() - .improvements(0L) - .metric(0.0) - .name("name") - .regressions(0L) - .unit("unit") - .diff(0.0) - .build() - assertThat(metricSummary).isNotNull - assertThat(metricSummary.improvements()).isEqualTo(0L) - assertThat(metricSummary.metric()).isEqualTo(0.0) - assertThat(metricSummary.name()).isEqualTo("name") - assertThat(metricSummary.regressions()).isEqualTo(0L) - assertThat(metricSummary.unit()).isEqualTo("unit") - assertThat(metricSummary.diff()).contains(0.0) + val metricSummary = MetricSummary.builder() + .improvements(0L) + .metric(0.0) + .name("name") + .regressions(0L) + .unit("unit") + .diff(0.0) + .build() + assertThat(metricSummary).isNotNull + assertThat(metricSummary.improvements()).isEqualTo(0L) + assertThat(metricSummary.metric()).isEqualTo(0.0) + assertThat(metricSummary.name()).isEqualTo("name") + assertThat(metricSummary.regressions()).isEqualTo(0L) + assertThat(metricSummary.unit()).isEqualTo("unit") + assertThat(metricSummary.diff()).contains(0.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt index 33f7f133..43f48d74 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt @@ -9,30 +9,22 @@ class OnlineScoreConfigTest { @Test fun createOnlineScoreConfig() { - val onlineScoreConfig = - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - assertThat(onlineScoreConfig).isNotNull - assertThat(onlineScoreConfig.samplingRate()).isEqualTo(0.0) - assertThat(onlineScoreConfig.scorers()) - .containsExactly( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) - assertThat(onlineScoreConfig.applyToRootSpan()).contains(true) - assertThat(onlineScoreConfig.applyToSpanNames().get()).containsExactly("string") + val onlineScoreConfig = OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + assertThat(onlineScoreConfig).isNotNull + assertThat(onlineScoreConfig.samplingRate()).isEqualTo(0.0) + assertThat(onlineScoreConfig.scorers()).containsExactly(OnlineScoreConfig.Scorer.ofFunction(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build())) + assertThat(onlineScoreConfig.applyToRootSpan()).contains(true) + assertThat(onlineScoreConfig.applyToSpanNames().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt index b86730ee..ca6c898c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt @@ -9,21 +9,20 @@ class OrganizationDeleteParamsTest { @Test fun create() { - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "organizationId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index 823cdd9c..989ed6d7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -10,41 +10,37 @@ class OrganizationListParamsTest { @Test fun create() { - OrganizationListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - OrganizationListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = OrganizationListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = OrganizationListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt index ccb97ded..edc65598 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt @@ -10,86 +10,71 @@ class OrganizationMemberUpdateParamsTest { @Test fun create() { - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() + OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() } @Test fun body() { - val params = - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() + val params = OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.inviteUsers()) - .contains( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - assertThat(body.orgId()).contains("org_id") - assertThat(body.orgName()).contains("org_name") - assertThat(body.removeUsers()) - .contains( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + assertNotNull(body) + assertThat(body.inviteUsers()).contains(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + assertThat(body.orgId()).contains("org_id") + assertThat(body.orgName()).contains("org_name") + assertThat(body.removeUsers()).contains(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = OrganizationMemberUpdateParams.builder().build() + val params = OrganizationMemberUpdateParams.builder().build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt index d7faaa14..3e1619c0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class OrganizationRetrieveParamsTest { @Test fun create() { - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "organizationId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt index d458dc17..84924053 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt @@ -10,24 +10,22 @@ class OrganizationTest { @Test fun createOrganization() { - val organization = - Organization.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .apiUrl("api_url") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .isUniversalApi(true) - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() - assertThat(organization).isNotNull - assertThat(organization.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(organization.name()).isEqualTo("name") - assertThat(organization.apiUrl()).contains("api_url") - assertThat(organization.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(organization.isUniversalApi()).contains(true) - assertThat(organization.proxyUrl()).contains("proxy_url") - assertThat(organization.realtimeUrl()).contains("realtime_url") + val organization = Organization.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .apiUrl("api_url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isUniversalApi(true) + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + assertThat(organization).isNotNull + assertThat(organization.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(organization.name()).isEqualTo("name") + assertThat(organization.apiUrl()).contains("api_url") + assertThat(organization.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(organization.isUniversalApi()).contains(true) + assertThat(organization.proxyUrl()).contains("proxy_url") + assertThat(organization.realtimeUrl()).contains("realtime_url") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt index 00ff172f..4bd931bb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt @@ -10,60 +10,57 @@ class OrganizationUpdateParamsTest { @Test fun create() { - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() } @Test fun body() { - val params = - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() + val params = OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.apiUrl()).contains("api_url") - assertThat(body.isUniversalApi()).contains(true) - assertThat(body.name()).contains("name") - assertThat(body.proxyUrl()).contains("proxy_url") - assertThat(body.realtimeUrl()).contains("realtime_url") + assertNotNull(body) + assertThat(body.apiUrl()).contains("api_url") + assertThat(body.isUniversalApi()).contains(true) + assertThat(body.name()).contains("name") + assertThat(body.proxyUrl()).contains("proxy_url") + assertThat(body.realtimeUrl()).contains("realtime_url") } @Test fun bodyWithoutOptionalFields() { - val params = - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "organizationId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt index dabc2d8c..0819b00a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt @@ -9,16 +9,14 @@ class PatchOrganizationMembersOutputTest { @Test fun createPatchOrganizationMembersOutput() { - val patchOrganizationMembersOutput = - PatchOrganizationMembersOutput.builder() - .orgId("org_id") - .status(PatchOrganizationMembersOutput.Status.SUCCESS) - .sendEmailError("send_email_error") - .build() - assertThat(patchOrganizationMembersOutput).isNotNull - assertThat(patchOrganizationMembersOutput.orgId()).isEqualTo("org_id") - assertThat(patchOrganizationMembersOutput.status()) - .isEqualTo(PatchOrganizationMembersOutput.Status.SUCCESS) - assertThat(patchOrganizationMembersOutput.sendEmailError()).contains("send_email_error") + val patchOrganizationMembersOutput = PatchOrganizationMembersOutput.builder() + .orgId("org_id") + .status(PatchOrganizationMembersOutput.Status.SUCCESS) + .sendEmailError("send_email_error") + .build() + assertThat(patchOrganizationMembersOutput).isNotNull + assertThat(patchOrganizationMembersOutput.orgId()).isEqualTo("org_id") + assertThat(patchOrganizationMembersOutput.status()).isEqualTo(PatchOrganizationMembersOutput.Status.SUCCESS) + assertThat(patchOrganizationMembersOutput.sendEmailError()).contains("send_email_error") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index 32b8bed3..6636e8d0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -10,27 +10,35 @@ class ProjectCreateParamsTest { @Test fun create() { - ProjectCreateParams.builder().name("x").orgName("org_name").build() + ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build() } @Test fun body() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.orgName()).contains("org_name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = ProjectCreateParams.builder().name("x").build() + val params = ProjectCreateParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt index b55b368f..de270023 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt @@ -9,17 +9,20 @@ class ProjectDeleteParamsTest { @Test fun create() { - ProjectDeleteParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectDeleteParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 2f0484be..8c574a5d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -10,44 +10,40 @@ class ProjectListParamsTest { @Test fun create() { - ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index d7a429e1..f32e301e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -11,109 +11,90 @@ class ProjectLogFeedbackParamsTest { @Test fun create() { - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - .build() + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - .build() + val params = ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder().id("id").build()) - .build() + val params = ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo(listOf(FeedbackProjectLogsItem.builder().id("id").build())) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .build())) } @Test fun getPathParam() { - val params = - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder().id("id").build()) - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .build()) + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt index 6e341ea3..9909aba6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt @@ -10,53 +10,50 @@ class ProjectLogFetchParamsTest { @Test fun create() { - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun queryParams() { - val params = - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("limit", "0") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index 9d2530b0..e924c459 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -10,60 +10,57 @@ class ProjectLogFetchPostParamsTest { @Test fun create() { - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun body() { - val params = - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + val params = ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.cursor()).contains("cursor") - assertThat(body.limit()).contains(0L) - assertThat(body.maxRootSpanId()).contains("max_root_span_id") - assertThat(body.maxXactId()).contains("max_xact_id") - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt index 24369344..1e5223c4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt @@ -12,207 +12,168 @@ class ProjectLogInsertParamsTest { @Test fun create() { - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + val params = ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()) - .isEqualTo( - listOf( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder().build()) - .build() + val params = ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder().build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) } @Test fun getPathParam() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder().build()) - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder().build()) + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt index d49aac8a..dd167ade 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt @@ -11,124 +11,100 @@ class ProjectLogsEventTest { @Test fun createProjectLogsEvent() { - val projectLogsEvent = - ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .addSpanParent("string") - .addTag("string") - .build() - assertThat(projectLogsEvent).isNotNull - assertThat(projectLogsEvent.id()).isEqualTo("id") - assertThat(projectLogsEvent._xactId()).isEqualTo("_xact_id") - assertThat(projectLogsEvent.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectLogsEvent.logId()).isEqualTo(ProjectLogsEvent.LogId.G) - assertThat(projectLogsEvent.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectLogsEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectLogsEvent.rootSpanId()).isEqualTo("root_span_id") - assertThat(projectLogsEvent.spanId()).isEqualTo("span_id") - assertThat(projectLogsEvent.context()) - .contains( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent.isRoot()).contains(true) - assertThat(projectLogsEvent.metadata()) - .contains( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(projectLogsEvent.metrics()) - .contains( - ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - assertThat(projectLogsEvent.origin()) - .contains( - ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent.scores()) - .contains( - ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(projectLogsEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) - assertThat(projectLogsEvent.spanParents().get()).containsExactly("string") - assertThat(projectLogsEvent.tags().get()).containsExactly("string") + val projectLogsEvent = ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build() + assertThat(projectLogsEvent).isNotNull + assertThat(projectLogsEvent.id()).isEqualTo("id") + assertThat(projectLogsEvent._xactId()).isEqualTo("_xact_id") + assertThat(projectLogsEvent.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectLogsEvent.logId()).isEqualTo(ProjectLogsEvent.LogId.G) + assertThat(projectLogsEvent.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectLogsEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectLogsEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(projectLogsEvent.spanId()).isEqualTo("span_id") + assertThat(projectLogsEvent.context()).contains(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.isRoot()).contains(true) + assertThat(projectLogsEvent.metadata()).contains(ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(projectLogsEvent.metrics()).contains(ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + assertThat(projectLogsEvent.origin()).contains(ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build()) + assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.scores()).contains(ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(projectLogsEvent.spanAttributes()).contains(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + assertThat(projectLogsEvent.spanParents().get()).containsExactly("string") + assertThat(projectLogsEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt index 071ceffa..7e1485f4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt @@ -9,19 +9,20 @@ class ProjectRetrieveParamsTest { @Test fun create() { - ProjectRetrieveParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt index 95a3b093..1ad3a943 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt @@ -9,9 +9,12 @@ class ProjectScoreCategoryTest { @Test fun createProjectScoreCategory() { - val projectScoreCategory = ProjectScoreCategory.builder().name("name").value(0.0).build() - assertThat(projectScoreCategory).isNotNull - assertThat(projectScoreCategory.name()).isEqualTo("name") - assertThat(projectScoreCategory.value()).isEqualTo(0.0) + val projectScoreCategory = ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build() + assertThat(projectScoreCategory).isNotNull + assertThat(projectScoreCategory.name()).isEqualTo("name") + assertThat(projectScoreCategory.value()).isEqualTo(0.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt index ebd3f975..f91c8470 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt @@ -9,41 +9,30 @@ class ProjectScoreConfigTest { @Test fun createProjectScoreConfig() { - val projectScoreConfig = - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - assertThat(projectScoreConfig).isNotNull - assertThat(projectScoreConfig.destination()) - .contains(ProjectScoreConfig.Destination.EXPECTED) - assertThat(projectScoreConfig.multiSelect()).contains(true) - assertThat(projectScoreConfig.online()) - .contains( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) + val projectScoreConfig = ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build() + assertThat(projectScoreConfig).isNotNull + assertThat(projectScoreConfig.destination()).contains(ProjectScoreConfig.Destination.EXPECTED) + assertThat(projectScoreConfig.multiSelect()).contains(true) + assertThat(projectScoreConfig.online()).contains(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt index f2eb7ba1..01e59ccc 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt @@ -10,117 +10,96 @@ class ProjectScoreCreateParamsTest { @Test fun create() { - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build() } @Test fun body() { - val params = - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() + val params = ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) - assertThat(body.categories()) - .contains( - ProjectScoreCreateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - ) - assertThat(body.config()) - .contains( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - assertThat(body.description()).contains("description") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertThat(body.categories()).contains(ProjectScoreCreateParams.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build()))) + assertThat(body.config()).contains(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .build() + val params = ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt index f341257a..948fc987 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt @@ -9,21 +9,20 @@ class ProjectScoreDeleteParamsTest { @Test fun create() { - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectScoreId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt index 6084f831..8aa8a527 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt @@ -10,59 +10,49 @@ class ProjectScoreListParamsTest { @Test fun create() { - ProjectScoreListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectScoreName("project_score_name") - .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectScoreName("project_score_name") + .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ProjectScoreListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectScoreName("project_score_name") - .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("project_score_name", "project_score_name") - expected.put( - "score_type", - ProjectScoreListParams.ScoreType.ofProject( - ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER.toString() - ) - .toString(), - ) - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectScoreName("project_score_name") + .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("project_score_name", "project_score_name") + expected.put("score_type", ProjectScoreListParams.ScoreType.ofProject(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER.toString()).toString()) + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectScoreListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectScoreListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt index 022d016b..5fc517ab 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt @@ -10,117 +10,96 @@ class ProjectScoreReplaceParamsTest { @Test fun create() { - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build() } @Test fun body() { - val params = - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() + val params = ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) - assertThat(body.categories()) - .contains( - ProjectScoreReplaceParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - ) - assertThat(body.config()) - .contains( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - assertThat(body.description()).contains("description") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertThat(body.categories()).contains(ProjectScoreReplaceParams.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build()))) + assertThat(body.config()).contains(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .build() + val params = ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt index d5ba83a1..2e00d311 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class ProjectScoreRetrieveParamsTest { @Test fun create() { - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectScoreId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt index 888ef861..74af95f8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt @@ -10,74 +10,58 @@ class ProjectScoreTest { @Test fun createProjectScore() { - val projectScore = - ProjectScore.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScore.ScoreType.SLIDER) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .position("position") - .build() - assertThat(projectScore).isNotNull - assertThat(projectScore.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectScore.name()).isEqualTo("name") - assertThat(projectScore.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectScore.scoreType()).isEqualTo(ProjectScore.ScoreType.SLIDER) - assertThat(projectScore.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectScore.categories()) - .contains( - ProjectScore.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - ) - assertThat(projectScore.config()) - .contains( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - assertThat(projectScore.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectScore.description()).contains("description") - assertThat(projectScore.position()).contains("position") + val projectScore = ProjectScore.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScore.ScoreType.SLIDER) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .position("position") + .build() + assertThat(projectScore).isNotNull + assertThat(projectScore.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectScore.name()).isEqualTo("name") + assertThat(projectScore.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectScore.scoreType()).isEqualTo(ProjectScore.ScoreType.SLIDER) + assertThat(projectScore.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectScore.categories()).contains(ProjectScore.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build()))) + assertThat(projectScore.config()).contains(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + assertThat(projectScore.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectScore.description()).contains("description") + assertThat(projectScore.position()).contains("position") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt index 7f153a84..411468cf 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt @@ -10,124 +10,102 @@ class ProjectScoreUpdateParamsTest { @Test fun create() { - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() } @Test fun body() { - val params = - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() + val params = ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.categories()) - .contains( - ProjectScoreUpdateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - ) - assertThat(body.config()) - .contains( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("name") - assertThat(body.scoreType()).contains(ProjectScoreUpdateParams.ScoreType.SLIDER) + assertNotNull(body) + assertThat(body.categories()).contains(ProjectScoreUpdateParams.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build()))) + assertThat(body.config()).contains(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + assertThat(body.scoreType()).contains(ProjectScoreUpdateParams.ScoreType.SLIDER) } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectScoreId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt index 0624066d..78b8b0dc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt @@ -9,8 +9,10 @@ class ProjectSettingsTest { @Test fun createProjectSettings() { - val projectSettings = ProjectSettings.builder().comparisonKey("comparison_key").build() - assertThat(projectSettings).isNotNull - assertThat(projectSettings.comparisonKey()).contains("comparison_key") + val projectSettings = ProjectSettings.builder() + .comparisonKey("comparison_key") + .build() + assertThat(projectSettings).isNotNull + assertThat(projectSettings.comparisonKey()).contains("comparison_key") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt index 04649ccf..f9195ece 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt @@ -10,45 +10,43 @@ class ProjectTagCreateParamsTest { @Test fun create() { - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() } @Test fun body() { - val params = - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).contains("color") - assertThat(body.description()).contains("description") + val params = ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt index 30ff07c4..6149efa2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt @@ -9,21 +9,20 @@ class ProjectTagDeleteParamsTest { @Test fun create() { - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectTagId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index b0008157..99c6c2e3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -10,50 +10,46 @@ class ProjectTagListParamsTest { @Test fun create() { - ProjectTagListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectTagName("project_tag_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectTagListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectTagName("project_tag_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ProjectTagListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectTagName("project_tag_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("project_tag_name", "project_tag_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectTagListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectTagName("project_tag_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("project_tag_name", "project_tag_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectTagListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectTagListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt index 9e25d87a..53ca1e92 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt @@ -10,45 +10,43 @@ class ProjectTagReplaceParamsTest { @Test fun create() { - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() } @Test fun body() { - val params = - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).contains("color") - assertThat(body.description()).contains("description") + val params = ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt index a1d9d5ee..041d9af1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class ProjectTagRetrieveParamsTest { @Test fun create() { - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectTagId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt index d9a83759..d8cdefb8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt @@ -10,23 +10,22 @@ class ProjectTagTest { @Test fun createProjectTag() { - val projectTag = - ProjectTag.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .build() - assertThat(projectTag).isNotNull - assertThat(projectTag.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectTag.name()).isEqualTo("name") - assertThat(projectTag.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectTag.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectTag.color()).contains("color") - assertThat(projectTag.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectTag.description()).contains("description") + val projectTag = ProjectTag.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .build() + assertThat(projectTag).isNotNull + assertThat(projectTag.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.name()).isEqualTo("name") + assertThat(projectTag.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.color()).contains("color") + assertThat(projectTag.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectTag.description()).contains("description") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt index 343aa380..24144f60 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt @@ -10,54 +10,51 @@ class ProjectTagUpdateParamsTest { @Test fun create() { - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() } @Test fun body() { - val params = - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.color()).contains("color") - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("name") + val params = ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectTagId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt index 390af485..0efd6798 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt @@ -10,24 +10,26 @@ class ProjectTest { @Test fun createProject() { - val project = - Project.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(project).isNotNull - assertThat(project.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(project.name()).isEqualTo("name") - assertThat(project.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(project.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(project.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(project.settings()) - .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) - assertThat(project.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val project = Project.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(project).isNotNull + assertThat(project.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(project.name()).isEqualTo("name") + assertThat(project.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(project.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(project.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(project.settings()).contains(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + assertThat(project.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 63716ab9..36d8c5bb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -10,48 +10,54 @@ class ProjectUpdateParamsTest { @Test fun create() { - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .build() + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .build() } @Test fun body() { - val params = - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).contains("name") - assertThat(body.settings()) - .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) + val params = ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).contains("name") + assertThat(body.settings()).contains(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 92e03d0c..81985d29 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -11,279 +11,174 @@ class PromptCreateParamsTest { @Test fun create() { - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionType()).contains(PromptCreateParams.FunctionType.LLM) - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionType()).contains(PromptCreateParams.FunctionType.LLM) + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index f2acf4d6..6d419229 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -10,151 +10,86 @@ class PromptDataTest { @Test fun createPromptData() { - val promptData = - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - assertThat(promptData).isNotNull - assertThat(promptData.options()) - .contains( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - assertThat(promptData.origin()) - .contains( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - assertThat(promptData.parser()) - .contains( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - assertThat(promptData.prompt()) - .contains( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - assertThat(promptData.toolFunctions().get()) - .containsExactly( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + val promptData = PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build() + assertThat(promptData).isNotNull + assertThat(promptData.options()).contains(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + assertThat(promptData.origin()).contains(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + assertThat(promptData.parser()).contains(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + assertThat(promptData.prompt()).contains(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + assertThat(promptData.toolFunctions().get()).containsExactly(PromptData.ToolFunction.ofFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build())) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt index ac1b91bb..729e3959 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt @@ -9,17 +9,20 @@ class PromptDeleteParamsTest { @Test fun create() { - PromptDeleteParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - PromptDeleteParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index 913ef416..9ff476ea 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -10,56 +10,52 @@ class PromptListParamsTest { @Test fun create() { - PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .promptName("prompt_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() + PromptListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .promptName("prompt_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() } @Test fun queryParams() { - val params = - PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .promptName("prompt_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("prompt_name", "prompt_name") - expected.put("slug", "slug") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = PromptListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .promptName("prompt_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("prompt_name", "prompt_name") + expected.put("slug", "slug") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = PromptListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = PromptListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt index 119a47b3..e2f8f9bc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt @@ -9,72 +9,42 @@ class PromptOptionsTest { @Test fun createPromptOptions() { - val promptOptions = - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - assertThat(promptOptions).isNotNull - assertThat(promptOptions.model()).contains("model") - assertThat(promptOptions.params()) - .contains( - PromptOptions.Params.ofOpenAIModel( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - ) - assertThat(promptOptions.position()).contains("position") + val promptOptions = PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build() + assertThat(promptOptions).isNotNull + assertThat(promptOptions.model()).contains("model") + assertThat(promptOptions.params()).contains(PromptOptions.Params.ofOpenAIModel(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build())) + assertThat(promptOptions.position()).contains("position") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 18d87eb2..22a37bc6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -11,279 +11,174 @@ class PromptReplaceParamsTest { @Test fun create() { - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionType()).contains(PromptReplaceParams.FunctionType.LLM) - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionType()).contains(PromptReplaceParams.FunctionType.LLM) + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt index 622fb8c9..322439c4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class PromptRetrieveParamsTest { @Test fun create() { - PromptRetrieveParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - PromptRetrieveParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index c65cd2c6..692fcfe0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -11,193 +11,118 @@ class PromptTest { @Test fun createPrompt() { - val prompt = - Prompt.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("_xact_id") - .logId(Prompt.LogId.P) - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .functionType(Prompt.FunctionType.LLM) - .metadata( - Prompt.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - assertThat(prompt).isNotNull - assertThat(prompt.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt._xactId()).isEqualTo("_xact_id") - assertThat(prompt.logId()).isEqualTo(Prompt.LogId.P) - assertThat(prompt.name()).isEqualTo("name") - assertThat(prompt.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt.slug()).isEqualTo("slug") - assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(prompt.description()).contains("description") - assertThat(prompt.functionType()).contains(Prompt.FunctionType.LLM) - assertThat(prompt.metadata()) - .contains( - Prompt.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(prompt.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(prompt.tags().get()).containsExactly("string") + val prompt = Prompt.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._xactId("_xact_id") + .logId(Prompt.LogId.P) + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .functionType(Prompt.FunctionType.LLM) + .metadata(Prompt.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() + assertThat(prompt).isNotNull + assertThat(prompt.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt._xactId()).isEqualTo("_xact_id") + assertThat(prompt.logId()).isEqualTo(Prompt.LogId.P) + assertThat(prompt.name()).isEqualTo("name") + assertThat(prompt.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt.slug()).isEqualTo("slug") + assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(prompt.description()).contains("description") + assertThat(prompt.functionType()).contains(Prompt.FunctionType.LLM) + assertThat(prompt.metadata()).contains(Prompt.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(prompt.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(prompt.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 7dae6fe3..1212ba35 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -11,279 +11,177 @@ class PromptUpdateParamsTest { @Test fun create() { - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .slug("slug") - .addTag("string") - .build() + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .slug("slug") + .addTag("string") + .build() } @Test fun body() { - val params = - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .slug("slug") - .addTag("string") - .build() + val params = PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .slug("slug") + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("name") - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.slug()).contains("slug") - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.slug()).contains("slug") + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt index 83eec5e0..a5d12e34 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt @@ -9,27 +9,26 @@ class RepoInfoTest { @Test fun createRepoInfo() { - val repoInfo = - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - assertThat(repoInfo).isNotNull - assertThat(repoInfo.authorEmail()).contains("author_email") - assertThat(repoInfo.authorName()).contains("author_name") - assertThat(repoInfo.branch()).contains("branch") - assertThat(repoInfo.commit()).contains("commit") - assertThat(repoInfo.commitMessage()).contains("commit_message") - assertThat(repoInfo.commitTime()).contains("commit_time") - assertThat(repoInfo.dirty()).contains(true) - assertThat(repoInfo.gitDiff()).contains("git_diff") - assertThat(repoInfo.tag()).contains("tag") + val repoInfo = RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + assertThat(repoInfo).isNotNull + assertThat(repoInfo.authorEmail()).contains("author_email") + assertThat(repoInfo.authorName()).contains("author_name") + assertThat(repoInfo.branch()).contains("branch") + assertThat(repoInfo.commit()).contains("commit") + assertThat(repoInfo.commitMessage()).contains("commit_message") + assertThat(repoInfo.commitTime()).contains("commit_time") + assertThat(repoInfo.dirty()).contains(true) + assertThat(repoInfo.gitDiff()).contains("git_diff") + assertThat(repoInfo.tag()).contains("tag") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt index 2a910fde..bfd19a81 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt @@ -10,67 +10,53 @@ class RoleCreateParamsTest { @Test fun create() { - RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = - RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberPermissions()) - .contains( - listOf( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberPermissions()).contains(listOf(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = RoleCreateParams.builder().name("x").build() + val params = RoleCreateParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt index 3d7f97a5..55d96c38 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt @@ -9,17 +9,20 @@ class RoleDeleteParamsTest { @Test fun create() { - RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + RoleDeleteParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = RoleDeleteParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 9a390aec..82eb0ae2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -10,44 +10,40 @@ class RoleListParamsTest { @Test fun create() { - RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("role_name", "role_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("role_name", "role_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = RoleListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = RoleListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt index 46264e88..d544cfc4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt @@ -10,67 +10,53 @@ class RoleReplaceParamsTest { @Test fun create() { - RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = - RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberPermissions()) - .contains( - listOf( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberPermissions()).contains(listOf(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = RoleReplaceParams.builder().name("x").build() + val params = RoleReplaceParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt index 696fe39a..10474e3d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class RoleRetrieveParamsTest { @Test fun create() { - RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + RoleRetrieveParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = RoleRetrieveParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt index 6187d100..5a7786a9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt @@ -10,38 +10,32 @@ class RoleTest { @Test fun createRole() { - val role = - Role.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .addMemberPermission( - Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(role).isNotNull - assertThat(role.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.name()).isEqualTo("name") - assertThat(role.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(role.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(role.description()).contains("description") - assertThat(role.memberPermissions().get()) - .containsExactly( - Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) - .build() - ) - assertThat(role.memberRoles().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val role = Role.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addMemberPermission(Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(role).isNotNull + assertThat(role.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.name()).isEqualTo("name") + assertThat(role.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(role.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(role.description()).contains("description") + assertThat(role.memberPermissions().get()).containsExactly(Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + assertThat(role.memberRoles().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt index ee226d14..d20c05b3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt @@ -10,108 +10,78 @@ class RoleUpdateParamsTest { @Test fun create() { - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.addMemberPermissions()) - .contains( - listOf( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.addMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("x") - assertThat(body.removeMemberPermissions()) - .contains( - listOf( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.removeMemberRoles()) - .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertNotNull(body) + assertThat(body.addMemberPermissions()).contains(listOf(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.addMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("x") + assertThat(body.removeMemberPermissions()).contains(listOf(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.removeMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun bodyWithoutOptionalFields() { - val params = - RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt index 35c169e5..08e71773 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt @@ -9,19 +9,18 @@ class ScoreSummaryTest { @Test fun createScoreSummary() { - val scoreSummary = - ScoreSummary.builder() - .improvements(0L) - .name("name") - .regressions(0L) - .score(0.0) - .diff(-1.0) - .build() - assertThat(scoreSummary).isNotNull - assertThat(scoreSummary.improvements()).isEqualTo(0L) - assertThat(scoreSummary.name()).isEqualTo("name") - assertThat(scoreSummary.regressions()).isEqualTo(0L) - assertThat(scoreSummary.score()).isEqualTo(0.0) - assertThat(scoreSummary.diff()).contains(-1.0) + val scoreSummary = ScoreSummary.builder() + .improvements(0L) + .name("name") + .regressions(0L) + .score(0.0) + .diff(-1.0) + .build() + assertThat(scoreSummary).isNotNull + assertThat(scoreSummary.improvements()).isEqualTo(0L) + assertThat(scoreSummary.name()).isEqualTo("name") + assertThat(scoreSummary.regressions()).isEqualTo(0L) + assertThat(scoreSummary.score()).isEqualTo(0.0) + assertThat(scoreSummary.diff()).contains(-1.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt index 562a0b8a..83cd4c86 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt @@ -9,10 +9,12 @@ class SpanAttributesTest { @Test fun createSpanAttributes() { - val spanAttributes = - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - assertThat(spanAttributes).isNotNull - assertThat(spanAttributes.name()).contains("name") - assertThat(spanAttributes.type()).contains(SpanAttributes.Type.LLM) + val spanAttributes = SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + assertThat(spanAttributes).isNotNull + assertThat(spanAttributes.name()).contains("name") + assertThat(spanAttributes.type()).contains(SpanAttributes.Type.LLM) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt index a972b937..e84b0503 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt @@ -10,28 +10,26 @@ class SpanIFrameTest { @Test fun createSpanIFrame() { - val spanIFrame = - SpanIFrame.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .postMessage(true) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(spanIFrame).isNotNull - assertThat(spanIFrame.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(spanIFrame.name()).isEqualTo("name") - assertThat(spanIFrame.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(spanIFrame.url()).isEqualTo("url") - assertThat(spanIFrame.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(spanIFrame.deletedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(spanIFrame.description()).contains("description") - assertThat(spanIFrame.postMessage()).contains(true) - assertThat(spanIFrame.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val spanIFrame = SpanIFrame.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .postMessage(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(spanIFrame).isNotNull + assertThat(spanIFrame.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(spanIFrame.name()).isEqualTo("name") + assertThat(spanIFrame.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(spanIFrame.url()).isEqualTo("url") + assertThat(spanIFrame.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(spanIFrame.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(spanIFrame.description()).contains("description") + assertThat(spanIFrame.postMessage()).contains(true) + assertThat(spanIFrame.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt index baf7a58f..6f3e3abe 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt @@ -10,50 +10,48 @@ class SpanIframeCreateParamsTest { @Test fun create() { - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() } @Test fun body() { - val params = - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") - assertThat(body.description()).contains("description") - assertThat(body.postMessage()).contains(true) + val params = SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + assertThat(body.description()).contains("description") + assertThat(body.postMessage()).contains(true) } @Test fun bodyWithoutOptionalFields() { - val params = - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") + val params = SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt index a1a4a437..dd3daa38 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt @@ -9,21 +9,20 @@ class SpanIframeDeleteParamsTest { @Test fun create() { - SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "spanIframeId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt index 50d720b8..7d25f092 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt @@ -10,44 +10,40 @@ class SpanIframeListParamsTest { @Test fun create() { - SpanIframeListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .spanIframeName("span_iframe_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + SpanIframeListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .spanIframeName("span_iframe_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - SpanIframeListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .spanIframeName("span_iframe_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("span_iframe_name", "span_iframe_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = SpanIframeListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .spanIframeName("span_iframe_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("span_iframe_name", "span_iframe_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = SpanIframeListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = SpanIframeListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt index 305c97ad..10f992e8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt @@ -10,50 +10,48 @@ class SpanIframeReplaceParamsTest { @Test fun create() { - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() } @Test fun body() { - val params = - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") - assertThat(body.description()).contains("description") - assertThat(body.postMessage()).contains(true) + val params = SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + assertThat(body.description()).contains("description") + assertThat(body.postMessage()).contains(true) } @Test fun bodyWithoutOptionalFields() { - val params = - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") + val params = SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt index ad6927a4..153e172c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class SpanIframeRetrieveParamsTest { @Test fun create() { - SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "spanIframeId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt index 57fce4c2..575579e0 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -10,54 +10,51 @@ class SpanIframeUpdateParamsTest { @Test fun create() { - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() } @Test fun body() { - val params = - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).contains("name") - assertThat(body.postMessage()).contains(true) - assertThat(body.url()).contains("url") + val params = SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).contains("name") + assertThat(body.postMessage()).contains(true) + assertThat(body.url()).contains("url") } @Test fun bodyWithoutOptionalFields() { - val params = - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "spanIframeId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt index a9675505..8a1b1547 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt @@ -9,20 +9,22 @@ class SummarizeDatasetResponseTest { @Test fun createSummarizeDatasetResponse() { - val summarizeDatasetResponse = - SummarizeDatasetResponse.builder() - .datasetName("dataset_name") - .datasetUrl("https://example.com") - .projectName("project_name") - .projectUrl("https://example.com") - .dataSummary(DataSummary.builder().totalRecords(0L).build()) - .build() - assertThat(summarizeDatasetResponse).isNotNull - assertThat(summarizeDatasetResponse.datasetName()).isEqualTo("dataset_name") - assertThat(summarizeDatasetResponse.datasetUrl()).isEqualTo("https://example.com") - assertThat(summarizeDatasetResponse.projectName()).isEqualTo("project_name") - assertThat(summarizeDatasetResponse.projectUrl()).isEqualTo("https://example.com") - assertThat(summarizeDatasetResponse.dataSummary()) - .contains(DataSummary.builder().totalRecords(0L).build()) + val summarizeDatasetResponse = SummarizeDatasetResponse.builder() + .datasetName("dataset_name") + .datasetUrl("https://example.com") + .projectName("project_name") + .projectUrl("https://example.com") + .dataSummary(DataSummary.builder() + .totalRecords(0L) + .build()) + .build() + assertThat(summarizeDatasetResponse).isNotNull + assertThat(summarizeDatasetResponse.datasetName()).isEqualTo("dataset_name") + assertThat(summarizeDatasetResponse.datasetUrl()).isEqualTo("https://example.com") + assertThat(summarizeDatasetResponse.projectName()).isEqualTo("project_name") + assertThat(summarizeDatasetResponse.projectUrl()).isEqualTo("https://example.com") + assertThat(summarizeDatasetResponse.dataSummary()).contains(DataSummary.builder() + .totalRecords(0L) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt index 35580e00..60d9d9a2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt @@ -10,88 +10,56 @@ class SummarizeExperimentResponseTest { @Test fun createSummarizeExperimentResponse() { - val summarizeExperimentResponse = - SummarizeExperimentResponse.builder() - .experimentName("experiment_name") - .experimentUrl("https://example.com") - .projectName("project_name") - .projectUrl("https://example.com") - .comparisonExperimentName("comparison_experiment_name") - .metrics( - SummarizeExperimentResponse.Metrics.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "improvements" to 0, - "metric" to 0, - "name" to "name", - "regressions" to 0, - "unit" to "unit", - "diff" to 0, - ) - ), - ) - .build() - ) - .scores( - SummarizeExperimentResponse.Scores.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "improvements" to 0, - "name" to "name", - "regressions" to 0, - "score" to 0, - "diff" to -1, - ) - ), - ) - .build() - ) - .build() - assertThat(summarizeExperimentResponse).isNotNull - assertThat(summarizeExperimentResponse.experimentName()).isEqualTo("experiment_name") - assertThat(summarizeExperimentResponse.experimentUrl()).isEqualTo("https://example.com") - assertThat(summarizeExperimentResponse.projectName()).isEqualTo("project_name") - assertThat(summarizeExperimentResponse.projectUrl()).isEqualTo("https://example.com") - assertThat(summarizeExperimentResponse.comparisonExperimentName()) - .contains("comparison_experiment_name") - assertThat(summarizeExperimentResponse.metrics()) - .contains( - SummarizeExperimentResponse.Metrics.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "improvements" to 0, - "metric" to 0, - "name" to "name", - "regressions" to 0, - "unit" to "unit", - "diff" to 0, - ) - ), - ) - .build() - ) - assertThat(summarizeExperimentResponse.scores()) - .contains( - SummarizeExperimentResponse.Scores.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "improvements" to 0, - "name" to "name", - "regressions" to 0, - "score" to 0, - "diff" to -1, - ) - ), - ) - .build() - ) + val summarizeExperimentResponse = SummarizeExperimentResponse.builder() + .experimentName("experiment_name") + .experimentUrl("https://example.com") + .projectName("project_name") + .projectUrl("https://example.com") + .comparisonExperimentName("comparison_experiment_name") + .metrics(SummarizeExperimentResponse.Metrics.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf( + "improvements" to 0, + "metric" to 0, + "name" to "name", + "regressions" to 0, + "unit" to "unit", + "diff" to 0, + ))) + .build()) + .scores(SummarizeExperimentResponse.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf( + "improvements" to 0, + "name" to "name", + "regressions" to 0, + "score" to 0, + "diff" to -1, + ))) + .build()) + .build() + assertThat(summarizeExperimentResponse).isNotNull + assertThat(summarizeExperimentResponse.experimentName()).isEqualTo("experiment_name") + assertThat(summarizeExperimentResponse.experimentUrl()).isEqualTo("https://example.com") + assertThat(summarizeExperimentResponse.projectName()).isEqualTo("project_name") + assertThat(summarizeExperimentResponse.projectUrl()).isEqualTo("https://example.com") + assertThat(summarizeExperimentResponse.comparisonExperimentName()).contains("comparison_experiment_name") + assertThat(summarizeExperimentResponse.metrics()).contains(SummarizeExperimentResponse.Metrics.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf( + "improvements" to 0, + "metric" to 0, + "name" to "name", + "regressions" to 0, + "unit" to "unit", + "diff" to 0, + ))) + .build()) + assertThat(summarizeExperimentResponse.scores()).contains(SummarizeExperimentResponse.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf( + "improvements" to 0, + "name" to "name", + "regressions" to 0, + "score" to 0, + "diff" to -1, + ))) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt index 56273dcf..7dd57e85 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt @@ -8,6 +8,6 @@ class TopLevelHelloWorldParamsTest { @Test fun create() { - TopLevelHelloWorldParams.builder().build() + TopLevelHelloWorldParams.builder().build() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 02f28453..3ad7d36d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -10,50 +10,46 @@ class UserListParamsTest { @Test fun create() { - UserListParams.builder() - .email("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName("string") - .givenName("string") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + UserListParams.builder() + .email("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName("string") + .givenName("string") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - UserListParams.builder() - .email("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName("string") - .givenName("string") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("email", UserListParams.Email.ofString("string").toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("family_name", UserListParams.FamilyName.ofString("string").toString()) - expected.put("given_name", UserListParams.GivenName.ofString("string").toString()) - expected.put( - "ids", - UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = UserListParams.builder() + .email("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName("string") + .givenName("string") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("email", UserListParams.Email.ofString("string").toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("family_name", UserListParams.FamilyName.ofString("string").toString()) + expected.put("given_name", UserListParams.GivenName.ofString("string").toString()) + expected.put("ids", UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = UserListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = UserListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt index f1686cc4..8d679477 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class UserRetrieveParamsTest { @Test fun create() { - UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + UserRetrieveParams.builder() + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "userId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = UserRetrieveParams.builder() + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "userId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt index fe6f4802..5de80102 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt @@ -10,21 +10,20 @@ class UserTest { @Test fun createUser() { - val user = - User.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .avatarUrl("avatar_url") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .email("email") - .familyName("family_name") - .givenName("given_name") - .build() - assertThat(user).isNotNull - assertThat(user.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(user.avatarUrl()).contains("avatar_url") - assertThat(user.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(user.email()).contains("email") - assertThat(user.familyName()).contains("family_name") - assertThat(user.givenName()).contains("given_name") + val user = User.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .avatarUrl("avatar_url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .familyName("family_name") + .givenName("given_name") + .build() + assertThat(user).isNotNull + assertThat(user.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(user.avatarUrl()).contains("avatar_url") + assertThat(user.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(user.email()).contains("email") + assertThat(user.familyName()).contains("family_name") + assertThat(user.givenName()).contains("given_name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt index 1f09c824..19223c9d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt @@ -12,138 +12,104 @@ class ViewCreateParamsTest { @Test fun create() { - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() } @Test fun body() { - val params = - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() + val params = ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) - assertThat(body.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.options()) - .contains( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()) - .contains( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) + assertThat(body.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()).contains(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()).contains(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .build() + val params = ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) - assertThat(body.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) + assertThat(body.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt index 7d1baa55..17b06040 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt @@ -10,20 +10,16 @@ class ViewDataSearchTest { @Test fun createViewDataSearch() { - val viewDataSearch = - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - assertThat(viewDataSearch).isNotNull - assertThat(viewDataSearch.filter().get()) - .containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.match().get()) - .containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.sort().get()) - .containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.tag().get()).containsExactly(JsonValue.from(mapOf())) + val viewDataSearch = ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + assertThat(viewDataSearch).isNotNull + assertThat(viewDataSearch.filter().get()).containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.match().get()).containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.sort().get()).containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.tag().get()).containsExactly(JsonValue.from(mapOf())) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt index 10157eee..86ef2bc6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt @@ -10,26 +10,20 @@ class ViewDataTest { @Test fun createViewData() { - val viewData = - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - assertThat(viewData).isNotNull - assertThat(viewData.search()) - .contains( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) + val viewData = ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build() + assertThat(viewData).isNotNull + assertThat(viewData.search()).contains(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt index 20ab82f1..fba424b7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt @@ -10,57 +10,54 @@ class ViewDeleteParamsTest { @Test fun create() { - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() } @Test fun body() { - val params = - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() + val params = ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } @Test fun bodyWithoutOptionalFields() { - val params = - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() + val params = ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } @Test fun getPathParam() { - val params = - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() - assertThat(params).isNotNull - // path param "viewId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt index 35c71549..56b75c4d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt @@ -10,56 +10,51 @@ class ViewListParamsTest { @Test fun create() { - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewName("view_name") - .viewType(ViewListParams.ViewType.PROJECTS) - .build() + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewName("view_name") + .viewType(ViewListParams.ViewType.PROJECTS) + .build() } @Test fun queryParams() { - val params = - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewName("view_name") - .viewType(ViewListParams.ViewType.PROJECTS) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("view_name", "view_name") - expected.put("view_type", ViewListParams.ViewType.PROJECTS.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewName("view_name") + .viewType(ViewListParams.ViewType.PROJECTS) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("view_name", "view_name") + expected.put("view_type", ViewListParams.ViewType.PROJECTS.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt index 3d6989ba..09ead451 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt @@ -10,33 +10,22 @@ class ViewOptionsTest { @Test fun createViewOptions() { - val viewOptions = - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - assertThat(viewOptions).isNotNull - assertThat(viewOptions.columnOrder().get()).containsExactly("string") - assertThat(viewOptions.columnSizing()) - .contains( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(viewOptions.columnVisibility()) - .contains( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) + val viewOptions = ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build() + assertThat(viewOptions).isNotNull + assertThat(viewOptions.columnOrder().get()).containsExactly("string") + assertThat(viewOptions.columnSizing()).contains(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(viewOptions.columnVisibility()).contains(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt index 069dcccd..cc4d9372 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt @@ -12,138 +12,104 @@ class ViewReplaceParamsTest { @Test fun create() { - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() } @Test fun body() { - val params = - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() + val params = ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) - assertThat(body.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.options()) - .contains( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()) - .contains( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) + assertThat(body.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()).contains(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()).contains(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .build() + val params = ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) - assertThat(body.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) + assertThat(body.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt index 31fdf385..ed35155f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt @@ -10,53 +10,50 @@ class ViewRetrieveParamsTest { @Test fun create() { - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() } @Test fun queryParams() { - val params = - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - assertThat(params).isNotNull - // path param "viewId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt index fd19dbb6..4ebef9a9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt @@ -11,81 +11,58 @@ class ViewTest { @Test fun createView() { - val view = - View.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(View.ObjectType.ORGANIZATION) - .viewType(View.ViewType.PROJECTS) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - assertThat(view).isNotNull - assertThat(view.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(view.name()).isEqualTo("name") - assertThat(view.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(view.objectType()).isEqualTo(View.ObjectType.ORGANIZATION) - assertThat(view.viewType()).contains(View.ViewType.PROJECTS) - assertThat(view.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(view.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(view.options()) - .contains( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(view.viewData()) - .contains( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) + val view = View.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(View.ObjectType.ORGANIZATION) + .viewType(View.ViewType.PROJECTS) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() + assertThat(view).isNotNull + assertThat(view.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(view.name()).isEqualTo("name") + assertThat(view.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(view.objectType()).isEqualTo(View.ObjectType.ORGANIZATION) + assertThat(view.viewType()).contains(View.ViewType.PROJECTS) + assertThat(view.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(view.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(view.options()).contains(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(view.viewData()).contains(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt index 67d83174..6208c9bb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt @@ -11,149 +11,114 @@ class ViewUpdateParamsTest { @Test fun create() { - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() } @Test fun body() { - val params = - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() + val params = ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) - assertThat(body.name()).contains("name") - assertThat(body.options()) - .contains( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()) - .contains( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - assertThat(body.viewType()).contains(ViewUpdateParams.ViewType.PROJECTS) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertThat(body.name()).contains("name") + assertThat(body.options()).contains(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()).contains(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + assertThat(body.viewType()).contains(ViewUpdateParams.ViewType.PROJECTS) } @Test fun bodyWithoutOptionalFields() { - val params = - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .build() + val params = ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) } @Test fun getPathParam() { - val params = - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .build() - assertThat(params).isNotNull - // path param "viewId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index 1d611bfb..76b08329 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -35,10 +35,9 @@ class ErrorHandlingTest { companion object { - private val ERROR: BraintrustError = - BraintrustError.builder() - .putAdditionalProperty("errorProperty", JsonValue.from("42")) - .build() + private val ERROR: BraintrustError = BraintrustError.builder() + .putAdditionalProperty("errorProperty", JsonValue.from("42")) + .build() private val ERROR_JSON: ByteArray = jsonMapper().writeValueAsBytes(ERROR) @@ -53,189 +52,231 @@ class ErrorHandlingTest { @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - client = - BraintrustOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.httpBaseUrl) - .apiKey("My API Key") - .build() + client = BraintrustOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() } @Test fun projectsCreate400() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(400) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate401() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(401) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate403() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(403) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate404() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(404) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate422() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(422) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate429() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(429) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate500() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(500) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate999() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(999) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(999) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreateInvalidJsonBody() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e).hasMessage("Error reading response") + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(200) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(NOT_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e).hasMessage("Error reading response") } private fun Headers.toMap(): Map> = diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt index 9e25370e..b65e3e95 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt @@ -26,33 +26,30 @@ internal class ServiceParamsTest { @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - client = - BraintrustOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.httpBaseUrl) - .apiKey("My API Key") - .build() + client = BraintrustOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() } @Test fun create() { - val projectService = client.projects() - stubFor(post(anyUrl()).willReturn(ok("{}"))) - - projectService.create( - ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .putAdditionalHeader("Secret-Header", "42") - .putAdditionalQueryParam("secret_query_param", "42") - .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) - .build() - ) - - verify( - postRequestedFor(anyUrl()) - .withHeader("Secret-Header", equalTo("42")) - .withQueryParam("secret_query_param", equalTo("42")) - .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) - ) + val projectService = client.projects() + stubFor(post(anyUrl()).willReturn(ok("{}"))) + + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build()) + + verify( + postRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt index 5df9416c..7c23deb9 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt @@ -18,155 +18,127 @@ class AclServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = - aclServiceAsync.create( - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val acl = aclFuture.get() - acl.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = aclServiceAsync.create(AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val acl = aclFuture.get() + acl.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = - aclServiceAsync.retrieve( - AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val acl = aclFuture.get() - acl.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = aclServiceAsync.retrieve(AclRetrieveParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val acl = aclFuture.get() + acl.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val pageFuture = - aclServiceAsync.list( - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .build() - ) - - val page = pageFuture.get() - page.response().validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val pageFuture = aclServiceAsync.list(AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build()) + + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = - aclServiceAsync.delete( - AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val acl = aclFuture.get() - acl.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = aclServiceAsync.delete(AclDeleteParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val acl = aclFuture.get() + acl.validate() } @Test fun batchUpdate() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclBatchUpdateResponseFuture = - aclServiceAsync.batchUpdate( - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) - - val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() - aclBatchUpdateResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclBatchUpdateResponseFuture = aclServiceAsync.batchUpdate(AclBatchUpdateParams.builder() + .addAddAcl(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build()) + + val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() + aclBatchUpdateResponse.validate() } @Test fun findAndDelete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = - aclServiceAsync.findAndDelete( - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val acl = aclFuture.get() - acl.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = aclServiceAsync.findAndDelete(AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val acl = aclFuture.get() + acl.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt index cc5d3c0a..c7a4be39 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams +import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams @@ -19,158 +20,130 @@ class AiSecretServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.create( - AiSecretCreateParams.builder() - .name("name") - .metadata( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.create(AiSecretCreateParams.builder() + .name("name") + .metadata(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.retrieve( - AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.retrieve(AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.update( - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .secret("secret") - .type("type") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.update(AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .secret("secret") + .type("type") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() - val pageFuture = aiSecretServiceAsync.list() + val pageFuture = aiSecretServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.delete( - AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.delete(AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun findAndDelete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.findAndDelete( - AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.findAndDelete(AiSecretFindAndDeleteParams.builder() + .name("name") + .orgName("org_name") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.replace( - AiSecretReplaceParams.builder() - .name("name") - .metadata( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.replace(AiSecretReplaceParams.builder() + .name("name") + .metadata(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt index f7d5a9ac..ab12b91e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams +import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -15,74 +16,64 @@ class ApiKeyServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val createApiKeyOutputFuture = - apiKeyServiceAsync.create( - ApiKeyCreateParams.builder().name("name").orgName("org_name").build() - ) + val createApiKeyOutputFuture = apiKeyServiceAsync.create(ApiKeyCreateParams.builder() + .name("name") + .orgName("org_name") + .build()) - val createApiKeyOutput = createApiKeyOutputFuture.get() - createApiKeyOutput.validate() + val createApiKeyOutput = createApiKeyOutputFuture.get() + createApiKeyOutput.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val apiKeyFuture = - apiKeyServiceAsync.retrieve( - ApiKeyRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val apiKeyFuture = apiKeyServiceAsync.retrieve(ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val apiKey = apiKeyFuture.get() - apiKey.validate() + val apiKey = apiKeyFuture.get() + apiKey.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val pageFuture = apiKeyServiceAsync.list() + val pageFuture = apiKeyServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val apiKeyFuture = - apiKeyServiceAsync.delete( - ApiKeyDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val apiKeyFuture = apiKeyServiceAsync.delete(ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val apiKey = apiKeyFuture.get() - apiKey.validate() + val apiKey = apiKeyFuture.get() + apiKey.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt index 4e6b2e1f..6dfc687d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams +import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams @@ -25,254 +26,205 @@ class DatasetServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = - datasetServiceAsync.create( - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - val dataset = datasetFuture.get() - dataset.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = datasetServiceAsync.create(DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .build()) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = - datasetServiceAsync.retrieve( - DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val dataset = datasetFuture.get() - dataset.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = datasetServiceAsync.retrieve(DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = - datasetServiceAsync.update( - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() - ) - - val dataset = datasetFuture.get() - dataset.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = datasetServiceAsync.update(DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .build()) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() - val pageFuture = datasetServiceAsync.list() + val pageFuture = datasetServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = - datasetServiceAsync.delete( - DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val dataset = datasetFuture.get() - dataset.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = datasetServiceAsync.delete(DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun feedback() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val feedbackResponseSchemaFuture = - datasetServiceAsync.feedback( - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) - - val feedbackResponseSchema = feedbackResponseSchemaFuture.get() - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val feedbackResponseSchemaFuture = datasetServiceAsync.feedback(DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build()) + .build()) + + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val fetchDatasetEventsResponseFuture = - datasetServiceAsync.fetch( - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val fetchDatasetEventsResponseFuture = datasetServiceAsync.fetch(DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() + fetchDatasetEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val fetchDatasetEventsResponseFuture = - datasetServiceAsync.fetchPost( - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val fetchDatasetEventsResponseFuture = datasetServiceAsync.fetchPost(DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() + fetchDatasetEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val insertEventsResponseFuture = - datasetServiceAsync.insert( - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) - - val insertEventsResponse = insertEventsResponseFuture.get() - insertEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val insertEventsResponseFuture = datasetServiceAsync.insert(DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) + + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() } @Test fun summarize() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val summarizeDatasetResponseFuture = - datasetServiceAsync.summarize( - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - ) - - val summarizeDatasetResponse = summarizeDatasetResponseFuture.get() - summarizeDatasetResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val summarizeDatasetResponseFuture = datasetServiceAsync.summarize(DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build()) + + val summarizeDatasetResponse = summarizeDatasetResponseFuture.get() + summarizeDatasetResponse.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt index b64fa2df..1d393bb4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt @@ -18,133 +18,109 @@ class EnvVarServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.create( - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.create(EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.retrieve( - EnvVarRetrieveParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.retrieve(EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.update( - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.update(EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.list( - EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.list(EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.delete( - EnvVarDeleteParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.delete(EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.replace( - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.replace(EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt index 406d7f7b..2dbf5ef8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt @@ -15,66 +15,54 @@ class EvalServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val evalServiceAsync = client.evals() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val evalServiceAsync = client.evals() - val summarizeExperimentResponseFuture = - evalServiceAsync.create( - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .task( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - .isPublic(true) - .maxConcurrency(0.0) - .metadata( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() - ) + val summarizeExperimentResponseFuture = evalServiceAsync.create(EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + .isPublic(true) + .maxConcurrency(0.0) + .metadata(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build()) - val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() - summarizeExperimentResponse.validate() + val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() + summarizeExperimentResponse.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt index e4ab67f2..d9925d89 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams @@ -27,329 +28,266 @@ class ExperimentServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = - experimentServiceAsync.create( - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("x") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() - ) - - val experiment = experimentFuture.get() - experiment.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = experimentServiceAsync.create(ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("x") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build()) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = - experimentServiceAsync.retrieve( - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val experiment = experimentFuture.get() - experiment.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = experimentServiceAsync.retrieve(ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = - experimentServiceAsync.update( - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() - ) - - val experiment = experimentFuture.get() - experiment.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = experimentServiceAsync.update(ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build()) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() - val pageFuture = experimentServiceAsync.list() + val pageFuture = experimentServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = - experimentServiceAsync.delete( - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val experiment = experimentFuture.get() - experiment.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = experimentServiceAsync.delete(ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun feedback() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val feedbackResponseSchemaFuture = - experimentServiceAsync.feedback( - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) - - val feedbackResponseSchema = feedbackResponseSchemaFuture.get() - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val feedbackResponseSchemaFuture = experimentServiceAsync.feedback(ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build()) + .build()) + + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val fetchExperimentEventsResponseFuture = - experimentServiceAsync.fetch( - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val fetchExperimentEventsResponseFuture = experimentServiceAsync.fetch(ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() + fetchExperimentEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val fetchExperimentEventsResponseFuture = - experimentServiceAsync.fetchPost( - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val fetchExperimentEventsResponseFuture = experimentServiceAsync.fetchPost(ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() + fetchExperimentEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val insertEventsResponseFuture = - experimentServiceAsync.insert( - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) - - val insertEventsResponse = insertEventsResponseFuture.get() - insertEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val insertEventsResponseFuture = experimentServiceAsync.insert(ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) + + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() } @Test fun summarize() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val summarizeExperimentResponseFuture = - experimentServiceAsync.summarize( - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - ) - - val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() - summarizeExperimentResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val summarizeExperimentResponseFuture = experimentServiceAsync.summarize(ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build()) + + val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() + summarizeExperimentResponse.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt index 58578b30..852d1e77 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams +import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams @@ -23,452 +24,297 @@ class FunctionServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.create( - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val functionFuture = functionServiceAsync.create(FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.retrieve( - FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val functionFuture = functionServiceAsync.retrieve(FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.update( - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val functionFuture = functionServiceAsync.update(FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val pageFuture = functionServiceAsync.list() + val pageFuture = functionServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.delete( - FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val functionFuture = functionServiceAsync.delete(FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun invoke() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val responseFuture = - functionServiceAsync.invoke( - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - .stream(true) - .version("version") - .build() - ) + val responseFuture = functionServiceAsync.invoke(FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build()) + .stream(true) + .version("version") + .build()) - val response = responseFuture.get() - val unwrappedResponse = response.getOrNull() - assertNotNull(unwrappedResponse) - unwrappedResponse.validate() + val response = responseFuture.get() + val unwrappedResponse = response.getOrNull() + assertNotNull(unwrappedResponse) + unwrappedResponse.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.replace( - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val functionFuture = functionServiceAsync.replace(FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt index 314e7023..d14aa978 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams +import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams @@ -17,128 +18,109 @@ class GroupServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.create( - GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.create(GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + val group = groupFuture.get() + group.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.retrieve( - GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.retrieve(GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val group = groupFuture.get() + group.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.update( - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.update(GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val group = groupFuture.get() + group.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() - val pageFuture = groupServiceAsync.list() + val pageFuture = groupServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.delete( - GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.delete(GroupDeleteParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val group = groupFuture.get() + group.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.replace( - GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.replace(GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + val group = groupFuture.get() + group.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt index b89247bd..d6f423f1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.OrganizationDeleteParams +import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import org.junit.jupiter.api.Test @@ -15,81 +16,68 @@ class OrganizationServiceAsyncTest { @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val organizationFuture = - organizationServiceAsync.retrieve( - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val organizationFuture = organizationServiceAsync.retrieve(OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val organization = organizationFuture.get() - organization.validate() + val organization = organizationFuture.get() + organization.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val organizationFuture = - organizationServiceAsync.update( - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() - ) + val organizationFuture = organizationServiceAsync.update(OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build()) - val organization = organizationFuture.get() - organization.validate() + val organization = organizationFuture.get() + organization.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val pageFuture = organizationServiceAsync.list() + val pageFuture = organizationServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val organizationFuture = - organizationServiceAsync.delete( - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val organizationFuture = organizationServiceAsync.delete(OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val organization = organizationFuture.get() - organization.validate() + val organization = organizationFuture.get() + organization.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt index efa55642..7ed089bb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.models.ProjectScoreCategory import com.braintrustdata.api.models.ProjectScoreConfig import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams +import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams @@ -20,191 +21,155 @@ class ProjectScoreServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.create( - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.create(ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.retrieve( - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.retrieve(ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.update( - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.update(ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() - val pageFuture = projectScoreServiceAsync.list() + val pageFuture = projectScoreServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.delete( - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.delete(ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.replace( - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.replace(ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt index 85f07a6a..b1b29862 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams +import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectSettings import com.braintrustdata.api.models.ProjectUpdateParams @@ -17,96 +18,84 @@ class ProjectServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = - projectServiceAsync.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - - val project = projectFuture.get() - project.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = projectServiceAsync.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + + val project = projectFuture.get() + project.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = - projectServiceAsync.retrieve( - ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val project = projectFuture.get() - project.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = projectServiceAsync.retrieve(ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val project = projectFuture.get() + project.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = - projectServiceAsync.update( - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .build() - ) - - val project = projectFuture.get() - project.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = projectServiceAsync.update(ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .build()) + + val project = projectFuture.get() + project.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() - val pageFuture = projectServiceAsync.list() + val pageFuture = projectServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = - projectServiceAsync.delete( - ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val project = projectFuture.get() - project.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = projectServiceAsync.delete(ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val project = projectFuture.get() + project.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt index 8105ac95..36d9a445 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams +import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams @@ -17,125 +18,104 @@ class ProjectTagServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.create( - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.create(ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.retrieve( - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.retrieve(ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.update( - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.update(ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() - val pageFuture = projectTagServiceAsync.list() + val pageFuture = projectTagServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.delete( - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.delete(ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.replace( - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.replace(ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt index 2535012d..a59c59a5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptDeleteParams +import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptOptions import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams @@ -20,358 +21,232 @@ class PromptServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.create( - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.create(PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.retrieve( - PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.retrieve(PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.update( - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .slug("slug") - .addTag("string") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.update(PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .slug("slug") + .addTag("string") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() - val pageFuture = promptServiceAsync.list() + val pageFuture = promptServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.delete( - PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.delete(PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.replace( - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.replace(PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt index 140fdec7..5f27b17c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams +import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams @@ -17,155 +18,121 @@ class RoleServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.create( - RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.create(RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + val role = roleFuture.get() + role.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.retrieve( - RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.retrieve(RoleRetrieveParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val role = roleFuture.get() + role.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.update( - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.update(RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val role = roleFuture.get() + role.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() - val pageFuture = roleServiceAsync.list() + val pageFuture = roleServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.delete( - RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.delete(RoleDeleteParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val role = roleFuture.get() + role.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.replace( - RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.replace(RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + val role = roleFuture.get() + role.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt index 8d448a50..b9d4a0bb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams @@ -17,127 +18,106 @@ class SpanIframeServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.create( - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.create(SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.retrieve( - SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.retrieve(SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.update( - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.update(SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() - val pageFuture = spanIframeServiceAsync.list() + val pageFuture = spanIframeServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.delete( - SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.delete(SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.replace( - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.replace(SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt index dee09b2e..8ac4b613 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.TopLevelHelloWorldParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -12,15 +13,14 @@ class TopLevelServiceAsyncTest { @Test fun helloWorld() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val topLevelServiceAsync = client.topLevel() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val topLevelServiceAsync = client.topLevel() - val responseFuture = topLevelServiceAsync.helloWorld() + val responseFuture = topLevelServiceAsync.helloWorld() - val response = responseFuture.get() + val response = responseFuture.get() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt index 38f452e7..082c2586 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -13,34 +14,31 @@ class UserServiceAsyncTest { @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userServiceAsync = client.users() - - val userFuture = - userServiceAsync.retrieve( - UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val user = userFuture.get() - user.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userServiceAsync = client.users() + + val userFuture = userServiceAsync.retrieve(UserRetrieveParams.builder() + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val user = userFuture.get() + user.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userServiceAsync = client.users() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userServiceAsync = client.users() - val pageFuture = userServiceAsync.list() + val pageFuture = userServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt index 8a7b3bfb..d86d5880 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt @@ -23,222 +23,168 @@ class ViewServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.create( - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.create(ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build()) + + val view = viewFuture.get() + view.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.retrieve( - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.retrieve(ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build()) + + val view = viewFuture.get() + view.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.update( - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.update(ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build()) + + val view = viewFuture.get() + view.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val pageFuture = - viewServiceAsync.list( - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .build() - ) - - val page = pageFuture.get() - page.response().validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val pageFuture = viewServiceAsync.list(ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build()) + + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.delete( - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.delete(ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build()) + + val view = viewFuture.get() + view.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.replace( - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.replace(ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build()) + + val view = viewFuture.get() + view.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt index 12efbd59..4710a3ed 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt @@ -13,39 +13,31 @@ class MemberServiceAsyncTest { @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val memberServiceAsync = client.organizations().members() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val memberServiceAsync = client.organizations().members() - val patchOrganizationMembersOutputFuture = - memberServiceAsync.update( - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) + val patchOrganizationMembersOutputFuture = memberServiceAsync.update(OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build()) - val patchOrganizationMembersOutput = patchOrganizationMembersOutputFuture.get() - patchOrganizationMembersOutput.validate() + val patchOrganizationMembersOutput = patchOrganizationMembersOutputFuture.get() + patchOrganizationMembersOutput.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt index fec1f6b8..492d6f27 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt @@ -21,162 +21,128 @@ class LogServiceAsyncTest { @Test fun feedback() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val feedbackResponseSchemaFuture = - logServiceAsync.feedback( - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) + val feedbackResponseSchemaFuture = logServiceAsync.feedback(ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build()) + .build()) - val feedbackResponseSchema = feedbackResponseSchemaFuture.get() - feedbackResponseSchema.validate() + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val fetchProjectLogsEventsResponseFuture = - logServiceAsync.fetch( - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) + val fetchProjectLogsEventsResponseFuture = logServiceAsync.fetch(ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) - val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() - fetchProjectLogsEventsResponse.validate() + val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() + fetchProjectLogsEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val fetchProjectLogsEventsResponseFuture = - logServiceAsync.fetchPost( - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) + val fetchProjectLogsEventsResponseFuture = logServiceAsync.fetchPost(ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) - val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() - fetchProjectLogsEventsResponse.validate() + val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() + fetchProjectLogsEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val insertEventsResponseFuture = - logServiceAsync.insert( - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) + val insertEventsResponseFuture = logServiceAsync.insert(ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) - val insertEventsResponse = insertEventsResponseFuture.get() - insertEventsResponse.validate() + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt index 499ca976..606645e8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt @@ -18,149 +18,121 @@ class AclServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = - aclService.create( - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = aclService.create(AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + acl.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = - aclService.retrieve( - AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = aclService.retrieve(AclRetrieveParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + acl.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val page = - aclService.list( - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .build() - ) - - page.response().validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val page = aclService.list(AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build()) + + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = - aclService.delete( - AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = aclService.delete(AclDeleteParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + acl.validate() } @Test fun batchUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val aclBatchUpdateResponse = - aclService.batchUpdate( - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) - - aclBatchUpdateResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val aclBatchUpdateResponse = aclService.batchUpdate(AclBatchUpdateParams.builder() + .addAddAcl(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build()) + + aclBatchUpdateResponse.validate() } @Test fun findAndDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = - aclService.findAndDelete( - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = aclService.findAndDelete(AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + acl.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt index 6da192a1..e3d4c517 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams +import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams @@ -19,151 +20,123 @@ class AiSecretServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.create( - AiSecretCreateParams.builder() - .name("name") - .metadata( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.create(AiSecretCreateParams.builder() + .name("name") + .metadata(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + + aISecret.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.retrieve( - AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.retrieve(AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + aISecret.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.update( - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .secret("secret") - .type("type") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.update(AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .secret("secret") + .type("type") + .build()) + + aISecret.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() - val page = aiSecretService.list() + val page = aiSecretService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.delete( - AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.delete(AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + aISecret.validate() } @Test fun findAndDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.findAndDelete( - AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.findAndDelete(AiSecretFindAndDeleteParams.builder() + .name("name") + .orgName("org_name") + .build()) + + aISecret.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.replace( - AiSecretReplaceParams.builder() - .name("name") - .metadata( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.replace(AiSecretReplaceParams.builder() + .name("name") + .metadata(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + + aISecret.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt index 46eefb44..3392aae9 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams +import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -15,70 +16,60 @@ class ApiKeyServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val createApiKeyOutput = - apiKeyService.create( - ApiKeyCreateParams.builder().name("name").orgName("org_name").build() - ) + val createApiKeyOutput = apiKeyService.create(ApiKeyCreateParams.builder() + .name("name") + .orgName("org_name") + .build()) - createApiKeyOutput.validate() + createApiKeyOutput.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val apiKey = - apiKeyService.retrieve( - ApiKeyRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val apiKey = apiKeyService.retrieve(ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - apiKey.validate() + apiKey.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val page = apiKeyService.list() + val page = apiKeyService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val apiKey = - apiKeyService.delete( - ApiKeyDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val apiKey = apiKeyService.delete(ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - apiKey.validate() + apiKey.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index a9bae5c4..62712f54 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams +import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams @@ -25,244 +26,195 @@ class DatasetServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = - datasetService.create( - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = datasetService.create(DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .build()) + + dataset.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = - datasetService.retrieve( - DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = datasetService.retrieve(DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + dataset.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = - datasetService.update( - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() - ) - - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = datasetService.update(DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .build()) + + dataset.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() - val page = datasetService.list() + val page = datasetService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = - datasetService.delete( - DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = datasetService.delete(DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + dataset.validate() } @Test fun feedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val feedbackResponseSchema = - datasetService.feedback( - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) - - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val feedbackResponseSchema = datasetService.feedback(DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build()) + .build()) + + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val fetchDatasetEventsResponse = - datasetService.fetch( - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val fetchDatasetEventsResponse = datasetService.fetch(DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + fetchDatasetEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val fetchDatasetEventsResponse = - datasetService.fetchPost( - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val fetchDatasetEventsResponse = datasetService.fetchPost(DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + fetchDatasetEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val insertEventsResponse = - datasetService.insert( - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) - - insertEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val insertEventsResponse = datasetService.insert(DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) + + insertEventsResponse.validate() } @Test fun summarize() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val summarizeDatasetResponse = - datasetService.summarize( - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - ) - - summarizeDatasetResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val summarizeDatasetResponse = datasetService.summarize(DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build()) + + summarizeDatasetResponse.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceTest.kt index 94340681..45209f68 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceTest.kt @@ -18,127 +18,103 @@ class EnvVarServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.create( - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.create(EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build()) + + envVar.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.retrieve( - EnvVarRetrieveParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.retrieve(EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + envVar.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.update( - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.update(EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build()) + + envVar.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.list( - EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.list(EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build()) + + envVar.validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.delete( - EnvVarDeleteParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.delete(EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + envVar.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.replace( - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.replace(EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build()) + + envVar.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt index feaa3f95..73833227 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt @@ -15,65 +15,53 @@ class EvalServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val evalService = client.evals() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val evalService = client.evals() - val summarizeExperimentResponse = - evalService.create( - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .task( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - .isPublic(true) - .maxConcurrency(0.0) - .metadata( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() - ) + val summarizeExperimentResponse = evalService.create(EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + .isPublic(true) + .maxConcurrency(0.0) + .metadata(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build()) - summarizeExperimentResponse.validate() + summarizeExperimentResponse.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt index b4e00567..a80c4a0c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams @@ -27,319 +28,256 @@ class ExperimentServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = - experimentService.create( - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("x") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() - ) - - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = experimentService.create(ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("x") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build()) + + experiment.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = - experimentService.retrieve( - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = experimentService.retrieve(ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + experiment.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = - experimentService.update( - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() - ) - - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = experimentService.update(ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build()) + + experiment.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() - val page = experimentService.list() + val page = experimentService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = - experimentService.delete( - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = experimentService.delete(ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + experiment.validate() } @Test fun feedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val feedbackResponseSchema = - experimentService.feedback( - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) - - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val feedbackResponseSchema = experimentService.feedback(ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build()) + .build()) + + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val fetchExperimentEventsResponse = - experimentService.fetch( - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val fetchExperimentEventsResponse = experimentService.fetch(ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + fetchExperimentEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val fetchExperimentEventsResponse = - experimentService.fetchPost( - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val fetchExperimentEventsResponse = experimentService.fetchPost(ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + fetchExperimentEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val insertEventsResponse = - experimentService.insert( - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) - - insertEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val insertEventsResponse = experimentService.insert(ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) + + insertEventsResponse.validate() } @Test fun summarize() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val summarizeExperimentResponse = - experimentService.summarize( - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - ) - - summarizeExperimentResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val summarizeExperimentResponse = experimentService.summarize(ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build()) + + summarizeExperimentResponse.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt index d5caebf7..2097fbb1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams +import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams @@ -23,445 +24,290 @@ class FunctionServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.create( - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val function = functionService.create(FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - function.validate() + function.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.retrieve( - FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val function = functionService.retrieve(FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - function.validate() + function.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.update( - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val function = functionService.update(FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - function.validate() + function.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val page = functionService.list() + val page = functionService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.delete( - FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val function = functionService.delete(FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - function.validate() + function.validate() } @Test fun invoke() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val response = - functionService.invoke( - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - .stream(true) - .version("version") - .build() - ) + val response = functionService.invoke(FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build()) + .stream(true) + .version("version") + .build()) - val unwrappedResponse = response.getOrNull() - assertNotNull(unwrappedResponse) - unwrappedResponse.validate() + val unwrappedResponse = response.getOrNull() + assertNotNull(unwrappedResponse) + unwrappedResponse.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.replace( - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val function = functionService.replace(FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - function.validate() + function.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index 5bb132ad..26f5904b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams +import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams @@ -17,122 +18,103 @@ class GroupServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.create( - GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.create(GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + group.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.retrieve( - GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.retrieve(GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + group.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.update( - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.update(GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + group.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() - val page = groupService.list() + val page = groupService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.delete( - GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.delete(GroupDeleteParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + group.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.replace( - GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.replace(GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + group.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt index 97c88d5c..a1dd9aeb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.OrganizationDeleteParams +import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import org.junit.jupiter.api.Test @@ -15,77 +16,64 @@ class OrganizationServiceTest { @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val organization = - organizationService.retrieve( - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val organization = organizationService.retrieve(OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - organization.validate() + organization.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val organization = - organizationService.update( - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() - ) + val organization = organizationService.update(OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build()) - organization.validate() + organization.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val page = organizationService.list() + val page = organizationService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val organization = - organizationService.delete( - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val organization = organizationService.delete(OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - organization.validate() + organization.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt index 0f7d4d1c..b9d3d052 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.models.ProjectScoreCategory import com.braintrustdata.api.models.ProjectScoreConfig import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams +import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams @@ -20,185 +21,149 @@ class ProjectScoreServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.create( - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.create(ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build()) + + projectScore.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.retrieve( - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.retrieve(ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + projectScore.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.update( - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.update(ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build()) + + projectScore.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() - val page = projectScoreService.list() + val page = projectScoreService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.delete( - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.delete(ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + projectScore.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.replace( - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.replace(ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build()) + + projectScore.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index 9b95d382..0759010d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams +import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectSettings import com.braintrustdata.api.models.ProjectUpdateParams @@ -17,91 +18,79 @@ class ProjectServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + + project.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = - projectService.retrieve( - ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = projectService.retrieve(ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + project.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = - projectService.update( - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .build() - ) - - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = projectService.update(ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .build()) + + project.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() - val page = projectService.list() + val page = projectService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = - projectService.delete( - ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = projectService.delete(ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + project.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt index 503f9390..dac7a1eb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams +import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams @@ -17,119 +18,98 @@ class ProjectTagServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.create( - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.create(ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + + projectTag.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.retrieve( - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.retrieve(ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + projectTag.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.update( - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.update(ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build()) + + projectTag.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() - val page = projectTagService.list() + val page = projectTagService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.delete( - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.delete(ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + projectTag.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.replace( - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.replace(ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + + projectTag.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 68eff58c..3edea5b3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptDeleteParams +import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptOptions import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams @@ -20,352 +21,226 @@ class PromptServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() - - val prompt = - promptService.create( - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) - - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() + + val prompt = promptService.create(PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) + + prompt.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() - val prompt = - promptService.retrieve( - PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val prompt = promptService.retrieve(PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - prompt.validate() + prompt.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() - - val prompt = - promptService.update( - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .slug("slug") - .addTag("string") - .build() - ) - - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() + + val prompt = promptService.update(PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .slug("slug") + .addTag("string") + .build()) + + prompt.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() - val page = promptService.list() + val page = promptService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() - val prompt = - promptService.delete( - PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val prompt = promptService.delete(PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - prompt.validate() + prompt.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() - - val prompt = - promptService.replace( - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) - - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() + + val prompt = promptService.replace(PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) + + prompt.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt index 87471933..b480a17c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams +import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams @@ -17,149 +18,115 @@ class RoleServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.create( - RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.create(RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + role.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.retrieve( - RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.retrieve(RoleRetrieveParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + role.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.update( - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.update(RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + role.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() - val page = roleService.list() + val page = roleService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.delete( - RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.delete(RoleDeleteParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + role.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.replace( - RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.replace(RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + role.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt index 0f18d989..158d05e0 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams @@ -17,121 +18,100 @@ class SpanIframeServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.create( - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.create(SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build()) + + spanIFrame.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.retrieve( - SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.retrieve(SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + spanIFrame.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.update( - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.update(SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build()) + + spanIFrame.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() - val page = spanIframeService.list() + val page = spanIframeService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.delete( - SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.delete(SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + spanIFrame.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.replace( - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.replace(SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build()) + + spanIFrame.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt index a1e4f554..b454e134 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.TopLevelHelloWorldParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -12,13 +13,12 @@ class TopLevelServiceTest { @Test fun helloWorld() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val topLevelService = client.topLevel() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val topLevelService = client.topLevel() - topLevelService.helloWorld() + topLevelService.helloWorld() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt index bdf88104..ca790444 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -13,32 +14,29 @@ class UserServiceTest { @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userService = client.users() - - val user = - userService.retrieve( - UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - user.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userService = client.users() + + val user = userService.retrieve(UserRetrieveParams.builder() + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + user.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userService = client.users() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userService = client.users() - val page = userService.list() + val page = userService.list() - page.response().validate() + page.response().validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt index 888e7466..4fb57c0c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt @@ -23,216 +23,162 @@ class ViewServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.create( - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.create(ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build()) + + view.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.retrieve( - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.retrieve(ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build()) + + view.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.update( - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.update(ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build()) + + view.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val page = - viewService.list( - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .build() - ) - - page.response().validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val page = viewService.list(ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build()) + + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.delete( - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.delete(ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build()) + + view.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.replace( - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.replace(ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build()) + + view.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt index d23dacb9..47cb2e31 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt @@ -13,38 +13,30 @@ class MemberServiceTest { @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val memberService = client.organizations().members() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val memberService = client.organizations().members() - val patchOrganizationMembersOutput = - memberService.update( - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) + val patchOrganizationMembersOutput = memberService.update(OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build()) - patchOrganizationMembersOutput.validate() + patchOrganizationMembersOutput.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt index fca0f5f6..128d5225 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt @@ -21,158 +21,124 @@ class LogServiceTest { @Test fun feedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val feedbackResponseSchema = - logService.feedback( - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) + val feedbackResponseSchema = logService.feedback(ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build()) + .build()) - feedbackResponseSchema.validate() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val fetchProjectLogsEventsResponse = - logService.fetch( - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) + val fetchProjectLogsEventsResponse = logService.fetch(ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) - fetchProjectLogsEventsResponse.validate() + fetchProjectLogsEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val fetchProjectLogsEventsResponse = - logService.fetchPost( - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) + val fetchProjectLogsEventsResponse = logService.fetchPost(ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) - fetchProjectLogsEventsResponse.validate() + fetchProjectLogsEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val insertEventsResponse = - logService.insert( - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) + val insertEventsResponse = logService.insert(ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) - insertEventsResponse.validate() + insertEventsResponse.validate() } }